begin process at 2010 09 07 18:21:55
  Trouver un code source :
 
dans
 
Accueil > Forum > 

PDA

 > 

Réseau & Internet

 > 

Sockets

 > 

chat cam entre PC et PCPOCKET dans VB.net par sockets


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

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


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Septembre 2010
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
27282930   

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,858 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales