اگه بتونید کاملش کنید میتونید یک چیزی تو مایه های Yahoo Messanger بسازسید در ویژال بیسیک یک پروژه جدید بسازید کپینش رو به Client تغیر بدید یک کمپونت WinSock Controler رو به برنامه اضافه کنید و اسم اونو TcpClient تغیر بدید دو تا Text Box به فرم اضافه کنید و اسم اولی رو txtSend و دومی رو txtOutput تغیر بدید یک CommandButton رو اضافه کنید و کپشنشو Connect و اسم اونو به cmdConnect تغیر بدید و کد پائین رو به اون اضافه کنید : Private Sub Form_Load() ' The name of the Winsock control is tcpClient. ' Note: to specify a remote host, you can use ' either the IP address (ex: "121.111.1.1") or ' the computer's "friendly" name, as shown here. tcpClient.RemoteHost = "RemoteComputerName" tcpClient.RemotePort = 1001 End Sub
Private Sub cmdConnect_Click() ' Invoke the Connect method to initiate a ' connection. tcpClient.Connect End Sub
Private Sub txtSendData_Change() tcpClient.SendData txtSend.Text End Sub
Private Sub tcpClient_DataArrival (ByVal bytesTotal As Long) Dim strData As String tcpClient.GetData strData txtOutput.Text = strData End Sub برنامه رو Exe کنید حالا نوبت سرور رسیده یک پروژه مثل بالا بسازید و همون چیز ها رو توش در بزارید اسم WinSock رو به tcpServer تغیر بدید بقیه نام ها مثل بالا باید با شند کپشن فرم هم باید TCP Server باشه و کد پانین رو وارد کنید :
Private Sub Form_Load() ' Set the LocalPort property to an integer. ' Then invoke the Listen method. tcpServer.LocalPort = 1001 tcpServer.Listen frmClient.Show ' Show the client form. End Sub
Private Sub tcpServer_ConnectionRequest (ByVal requestID As Long) ' Check if the control's State is closed. If not, ' close the connection before accepting the new ' connection. If tcpServer.State <> sckClosed Then _ tcpServer.Close ' Accept the request with the requestID ' parameter. tcpServer.Accept requestID End Sub
Private Sub txtSendData_Change() ' The TextBox control named txtSendData ' contains the data to be sent. Whenever the user ' types into the textbox, the string is sent ' using the SendData method. tcpServer.SendData txtSendData.Text End Sub
Private Sub tcpServer_DataArrival (ByVal bytesTotal As Long) ' Declare a variable for the incoming data. ' Invoke the GetData method and set the Text ' property of a TextBox named txtOutput to ' the data. Dim strData As String tcpServer.GetData strData txtOutput.Text = strData End Sub
و این هم Exe کنید با ید IP کامپیوتر خوتون رو به برنامه Client بدید. با دستور Ipconfig توی Ms_Dos Mode می توانید IP خودتون رو ببینید