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
lire un stream dans des cartes son externes [ par sawass ]
Bonjour j'ai un code qui permet de faire sortir un stream en temps réel.Je parle au microphone de l'ordinateur et le son sorte du carte son de l'ordin
Google Weather sur WP7 [ par jihednond ]
Bonjour, j'ai crée un code qui affiche le temps pour une région bien déterminé,en utilisant google weather, mais il ne m'affiche rien,j'ai même essayé
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
Livres en rapport
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Forum
MIDLET ET XMLMIDLET ET XML par hadassah
Cliquez pour lire la suite par hadassah
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|