Accueil > Forum > > > > chat cam entre PC et PCPOCKET dans VB.net par sockets
chat cam entre PC et PCPOCKET dans VB.net par sockets
mardi 9 février 2010 à 01:12:09 |
chat cam entre PC et PCPOCKET dans VB.net par sockets

sososamir
|
bon jour a tous le mond j'ais besoin de votre aide je vient de faire une application de chatt avec la camera entre une client qui est un PC et le serveur qui 'est un PC POCkET avec le protocol TCP dans VB.net par le socket j'ais d'éja une application de chat cam entre 2 PC qui march bien mais le problem que l'environement du PC Pocket ne conné pas Image.FromStream mon code pour le serveur dans une form de smart divace est :
Code Visual Basic : Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Net.Sockets
Imports System.IO
Imports System.Threading
Namespace Server
Public Class Form1 : Inherits System.Windows.Forms.Form
Private components As System.ComponentModel.Container = Nothing
Public Sub New()
'
' Required for Windows Form Designer support
'
InitializeComponent()
'
' TODO: Add any constructor code after InitializeComponent call
'
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#Region "Windows Form Designer generated code"
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
Me.pictureBox1 = New System.Windows.Forms.PictureBox()
Me.SuspendLayout()
'
' pictureBox1
'
Me.pictureBox1.BackColor = System.Drawing.Color.Black
Me.pictureBox1.Location = New System.Drawing.Point(0, 0)
Me.pictureBox1.Name = "pictureBox1"
Me.pictureBox1.Size = New System.Drawing.Size(192, 120)
Me.pictureBox1.TabIndex = 6
Me.pictureBox1.TabStop = False
'
' Form1
'
Me.BackColor = System.Drawing.Color.Black
Me.ClientSize = New System.Drawing.Size(186, 120)
Me.Controls.Add(Me.pictureBox1)
Me.ForeColor = System.Drawing.Color.Black
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Name = "Form1"
Me.Text = "Server Form"
' Me.Closing += New System.ComponentModel.CancelEventHandler(Me.Form1_Closing);
' Me.Load += New System.EventHandler(Me.Form1_Load);
Me.ResumeLayout(False)
End Sub
#End Region
<STAThread()> _
Shared Sub Main()
Application.Run(New Form1())
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myth As Thread
myth = New Thread(New System.Threading.ThreadStart(AddressOf StartMethod)) ' Start Thread Session
myth.Start()
End Sub
Private Sub StartMethod()
mytcpl = New TcpListener(5020) ' Open The Port
mytcpl.Start() ' Start Listening on That Port
mysocket = mytcpl.AcceptSocket() ' Accept Any Request From Client and Start a Session
myns = New NetworkStream(mysocket) ' Receives The Binary Data From Port
pictureBox1.Image = Image.FromStream(myns)
mytcpl.Stop() ' Close TCP Session
If mysocket.Connected = True Then ' Looping While Connected to Receive Another Message
Do While True
StartMethod() ' Back to First Method
Loop
End If
End Sub
Private mytcpl As TcpListener ' Objects Declaration
Private mysocket As Socket
Private pictureBox1 As System.Windows.Forms.PictureBox
Private myns As NetworkStream
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Try
mytcpl.Stop()
Application.ExitThread()
Application.Exit()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
End Namespace
est pour le client qui est le PC est :
Code Visual Basic : Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Net.Sockets
Imports System.IO
Namespace Client
''' <summary>
''' Summary description for Form1.
''' </summary>
Public Class Form1 : Inherits System.Windows.Forms.Form
Public num As Integer=0
Public sec As Integer=0
Private txt_host As System.Windows.Forms.TextBox
Private label1 As System.Windows.Forms.Label
Private pictureBox1 As System.Windows.Forms.PictureBox
Private WithEvents button2 As System.Windows.Forms.Button
Private webCamCapture1 As WebCam_Capture.WebCamCapture
Private WithEvents WebCamCapture As WebCam_Capture.WebCamCapture
Private WithEvents button3 As System.Windows.Forms.Button
Private WithEvents button1 As System.Windows.Forms.Button
Private WithEvents button4 As System.Windows.Forms.Button
Private WithEvents timer1 As System.Windows.Forms.Timer
Private WithEvents button5 As System.Windows.Forms.Button
Private components As System.ComponentModel.IContainer
Public Sub New()
'
' Required for Windows Form Designer support
'
InitializeComponent()
'
' TODO: Add any constructor code after InitializeComponent call
'
End Sub
''' <summary>
''' Clean up any resources being used.
''' </summary>
Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#Region "Windows Form Designer generated code"
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.txt_host = New System.Windows.Forms.TextBox()
Me.label1 = New System.Windows.Forms.Label()
Me.pictureBox1 = New System.Windows.Forms.PictureBox()
Me.button2 = New System.Windows.Forms.Button()
Me.WebCamCapture = New WebCam_Capture.WebCamCapture()
Me.button3 = New System.Windows.Forms.Button()
Me.button1 = New System.Windows.Forms.Button()
Me.button4 = New System.Windows.Forms.Button()
Me.timer1 = New System.Windows.Forms.Timer(Me.components)
Me.button5 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
' txt_host
'
Me.txt_host.Location = New System.Drawing.Point(80, 8)
Me.txt_host.Name = "txt_host"
Me.txt_host.Size = New System.Drawing.Size(200, 20)
Me.txt_host.TabIndex = 2
Me.txt_host.Text = "localhost"
'
' label1
'
Me.label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (CByte(178)))
Me.label1.Location = New System.Drawing.Point(16, 8)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(56, 23)
Me.label1.TabIndex = 3
Me.label1.Text = "Server"
'
' pictureBox1
'
Me.pictureBox1.BackColor = System.Drawing.Color.Black
Me.pictureBox1.Location = New System.Drawing.Point(184, 40)
Me.pictureBox1.Name = "pictureBox1"
Me.pictureBox1.Size = New System.Drawing.Size(192, 120)
Me.pictureBox1.TabIndex = 5
Me.pictureBox1.TabStop = False
'
' button2
'
Me.button2.Enabled = False
Me.button2.Location = New System.Drawing.Point(32, 120)
Me.button2.Name = "button2"
Me.button2.Size = New System.Drawing.Size(112, 23)
Me.button2.TabIndex = 6
Me.button2.Text = "Send a Picture"
' Me.button2.Click += New System.EventHandler(Me.button2_Click);
'
' WebCamCapture
'
Me.WebCamCapture.CaptureHeight = 240
Me.WebCamCapture.CaptureWidth = 320
' TODO: Code generation for 'this.WebCamCapture.FrameNumber' failed because of Exception 'Invalid Primitive Type: System.UInt64. Only CLS compliant primitive types can be used. Consider using CodeObjectCreateExpression.'.
Me.WebCamCapture.Location = New System.Drawing.Point(17, 17)
Me.WebCamCapture.Name = "WebCamCapture"
Me.WebCamCapture.Size = New System.Drawing.Size(342, 252)
Me.WebCamCapture.TabIndex = 0
Me.WebCamCapture.TimeToCapture_milliseconds = 100
' Me.WebCamCapture.ImageCaptured += New WebCam_Capture.WebCamCapture.WebCamEventHandler(Me.WebCamCapture_ImageCaptured_1);
'
' button3
'
Me.button3.Location = New System.Drawing.Point(8, 48)
Me.button3.Name = "button3"
Me.button3.Size = New System.Drawing.Size(112, 23)
Me.button3.TabIndex = 7
Me.button3.Text = "Plug Camera"
' Me.button3.Click += New System.EventHandler(Me.button3_Click);
'
' button1
'
Me.button1.Enabled = False
Me.button1.Location = New System.Drawing.Point(8, 80)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(80, 23)
Me.button1.TabIndex = 8
Me.button1.Text = "Start Stream"
' Me.button1.Click += New System.EventHandler(Me.button1_Click);
'
' button4
'
Me.button4.Enabled = False
Me.button4.Location = New System.Drawing.Point(96, 80)
Me.button4.Name = "button4"
Me.button4.Size = New System.Drawing.Size(80, 23)
Me.button4.TabIndex = 9
Me.button4.Text = "Stop Stream"
' Me.button4.Click += New System.EventHandler(Me.button4_Click);
'
' timer1
'
' Me.timer1.Tick += New System.EventHandler(Me.timer1_Tick);
'
' button5
'
Me.button5.Enabled = False
Me.button5.Location = New System.Drawing.Point(128, 48)
Me.button5.Name = "button5"
Me.button5.Size = New System.Drawing.Size(48, 23)
Me.button5.TabIndex = 10
Me.button5.Text = "Stop"
' Me.button5.Click += New System.EventHandler(Me.button5_Click);
'
' Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(386, 176)
Me.Controls.Add(Me.button5)
Me.Controls.Add(Me.button4)
Me.Controls.Add(Me.button1)
Me.Controls.Add(Me.button3)
Me.Controls.Add(Me.button2)
Me.Controls.Add(Me.pictureBox1)
Me.Controls.Add(Me.label1)
Me.Controls.Add(Me.txt_host)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Client Form"
' Me.Load += New System.EventHandler(Me.Form1_Load);
Me.ResumeLayout(False)
End Sub
#End Region
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread> _
Shared Sub Main()
Application.Run(New Form1())
End Sub
Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button2.Click
Try
Dim ms As MemoryStream = New MemoryStream() ' Store it in Binary Array as Stream
pictureBox1.Image.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage As Byte() = ms.GetBuffer()
ms.Close()
Dim myclient As TcpClient = New TcpClient (txt_host.Text,5020) 'Connecting with server
Dim myns As NetworkStream = myclient.GetStream ()
Dim mysw As BinaryWriter = New BinaryWriter (myns)
mysw.Write(arrImage) 'send the stream to above address
mysw.Close ()
myns.Close ()
myclient.Close ()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub webCamCapture1_ImageCaptured(ByVal source As Object, ByVal e As WebCam_Capture.WebcamEventArgs)
Try
Me.pictureBox1.Image = e.WebCamImage
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub WebCamCapture_ImageCaptured(ByVal source As Object, ByVal e As WebCam_Capture.WebcamEventArgs)
Try
Me.pictureBox1.Image = e.WebCamImage
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub WebCamCapture_ImageCaptured_1(ByVal source As Object, ByVal e As WebCam_Capture.WebcamEventArgs) Handles WebCamCapture.ImageCaptured
pictureBox1.Image = e.WebCamImage
End Sub
Private Sub button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button3.Click
Try
' Camera Configuration
Me.WebCamCapture.CaptureHeight = Me.pictureBox1.Height
Me.WebCamCapture.CaptureWidth = Me.pictureBox1.Width
Me.WebCamCapture.TimeToCapture_milliseconds = 20
Me.WebCamCapture.Start(UInt64.Parse(0))
button1.Enabled = True
button2.Enabled = True
button5.Enabled = True
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer1.Tick
button2_Click(sender, e)
sec +=1
Me.Text ="Client Form" & " Frame # " & sec.ToString ()
End Sub
Private Sub button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button4.Click
sec = 0
timer1.Enabled = False
button2.Enabled = True
Me.Text ="Client Form"
button4.Enabled = False
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
timer1.Enabled = True
button2.Enabled = False
button4.Enabled = True
End Sub
Private Sub button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button5.Click
Me.WebCamCapture.Stop ()
button5.Enabled = False
End Sub
End Class
End Namespace
|
|
Cette discussion est classée dans : end, windows, system, private, drawing
Répondre à ce message
Sujets en rapport avec ce message
Actulisation/ouverture d'une fenêtre sur PDA en C# [ par Diafwl1 ]
Bonjour, Je suis en trein de faire des tests sur PDA et j'ai un petit problème, je n'arrive pas à afficher une fenêtre par dessous une autre (ou actul
[C# - NETCF3.5] PictureBox transparent [ par neo2k2 ]
Bonjour, cette question étant souvent abordée, je vous la repose néanmoins avec mon code afin que l'on puisse m'expliquer et/ou corriger ce qui ne va
Rediriger port com vers Bluetooth ou câble sous Windows Mobile 6 et PocketDOS [ par TRIMBLE6TEM ]
Topo6tem j'ai développé de manière autodidacte un logiciel sous Quick Basic (DOS)spécialisé pour les activités de Géomètres.Actuellement
C# - Compact Framework lister fichiers [ par neo2k2 ]
Bonjour à tous!Encore une question concernant Windows Mobile... J'ai fait une petite application contenant une listbox dans laquelle j'affiche les fic
Problème pour installer thème @ windows mobile [ par VAIOvgn ]
Bonjour, je viens pour poser une question simple mais qui m'embête vraiment. Je viens d'avoir un PAD iPAQ de chez HP qui tourne donc sous Windows mobi
Migrer un projet win32 -> windows mobile [ par HCJarod ]
Salut,j'ai donc une solution avec 2 projets (dll c++ et appli c#) qui tourne bien sur pc. Est-il possible (j'ai bien l'impression que oui) de changer
NullReferenceException et resultat requete vide [ par djeje44800 ]
Bonjour, developpant en stage une application pour PDA, je fais de nombreux essais pour comprendre la logique du code (n'ayant jamais développer sur P
Pb:Connexion à une base SqlServer 2005 via WinCe, dev sous VB.net [ par aaqilovich ]
voici mon codeTry'Chaîne de connexion<f
OpenNETCF upload [ par bobjoumi ]
Avec OpenNETCF voila ce que je fais mais mon problème c'est que je n'arrives pas a fair mon upload...Code:using System;using System.Linq;using System.
vb.net - Jouer .wav sous Windows Mobile 6 [ par CodeIX ]
Bonjour, j'aimerais savoir ou est mon probleme lorsque j'essaie de jouer un son .WAV dans Windows Mobile 6? A chaque fois que j'essaie de jouer mon f
Livres en rapport
|
Derniers Blogs
WINDBG / SOS / PSSCOR2 : FAILED TO LOAD DATA ACCESS DLL (MSCORDACWKS)WINDBG / SOS / PSSCOR2 : FAILED TO LOAD DATA ACCESS DLL (MSCORDACWKS) par coq
Ceux d'entre nous qui analysent des dumps d'applications .NET (notamment ceux créés via WER après un crash) en dehors de l'environnement initial ont probablement tous été confrontés au moins une fois au message suivant, à la saisie d'une commande SOS ...
Cliquez pour lire la suite de l'article par coq PERSPECTIVE 2.0 : VERSION FINALEPERSPECTIVE 2.0 : VERSION FINALE par odewit
La version 2.0 de Perspective pour WPF 4 est sortie.
Les nouveautés sont décrites dans l'annonce de la version bêta. ...
Cliquez pour lire la suite de l'article par odewit SHAREPOINT 2010 : COMPARAISON ENTRE LA VERSION 2007 ET LA VERSION 2010SHAREPOINT 2010 : COMPARAISON ENTRE LA VERSION 2007 ET LA VERSION 2010 par phil
Avant de passer en mode "rentrée" pour la reprise en main de ce blog après une longue période de vacances, j'en profite pour poster quelsues liens qui m'ont été bien utiles pour expliquer, depuis quelques mois déjà, quelles différences il existe en te...
Cliquez pour lire la suite de l'article par phil
Logiciels
Secunia PSI (2.0 béta)SECUNIA PSI (2.0 BéTA)Utiliser de vieilles versions des logiciels peut être dangereux : par exemple utiliser une vieill... Cliquez pour télécharger Secunia PSI Update Checker (FileHippo.com) (1.038)UPDATE CHECKER (FILEHIPPO.COM) (1.038)Update Checker est un logiciel qui permet de trouver la liste des logiciels installés sur votre P... Cliquez pour télécharger Update Checker (FileHippo.com) FVD Suite (2.4.7)FVD SUITE (2.4.7)FVD Suite convertit rapidement vos fichiers audio ou vidéo vers la plupart d'autres formats que l... Cliquez pour télécharger FVD Suite Miro video converter (2.4)MIRO VIDEO CONVERTER (2.4)Miro Video Converter convertit n'importe quelle vidéo pour permettre sa lecture sur iPhone, Andro... Cliquez pour télécharger Miro video converter VLC (1.1.4)VLC (1.1.4)VLC Media Player est un lecteur multimédia extrêmement léger. La consommation en ressources du pr... Cliquez pour télécharger VLC
|