![]() |
Click here to advertise with us
|
|
|||||||
| Net / Sockets Components for network and related use |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hey,
I am looking for help in solving a problem I have. I have a code for client server application taken from the visual studio 2008 help. The thing is it is written in VB6 and I have been working for hours now trying to make the adjustments so it would work but still havn't been successful. I started thinking about leaving VB and just write everything in python. Before giving up, I decided to try and get help in here. The specific problem is that pressing the connect button in the client's form doesn't seem to have any result. --------------------------------------- server 's code: Public Class frmServer Private Sub frmServer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Set the LocalPort property to an integer. ' Then invoke the Listen method. tcpServer.LocalPort = 8000 tcpServer.Listen() frmClient.Show() ' Show the client form. End Sub Private Sub tcpServer_ConnectionRequest _ (ByVal requestID As Long) MsgBox("333") ' Check if the control's State is closed. If not, ' close the connection before accepting the new ' connection. If tcpServer.CtlState <> "8" Then _ tcpServer.Close() ' Accept the request with the requestID ' parameter. tcpServer.Accept(requestID) End Sub Private Sub txtSendData_Change() MsgBox("444") ' 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) MsgBox("555") ' 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 strData = String.Empty tcpServer.GetData(strData) txtOutput.Text = strData End Sub End Class --------------------------------------------------- client's code: Public Class frmClient Private Sub frmClient_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.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. f45d87107 ' tcpClient.RemoteHost = "192.168.2.201" tcpClient.RemoteHost = "127.0.0.1" tcpClient.RemotePort = 8000 End Sub Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click ' Invoke the Connect method to initiate a connection. 'tcpClient.Connect("127.0.0.1", 1001) tcpClient.Connect("127.0.0.1", 8000) MsgBox("000") End Sub Private Sub txtSend_Change() MsgBox("111") tcpClient.SendData(txtSend.Text) End Sub Private Sub tcpClient_DataArrival _ (ByVal bytesTotal As Long) MsgBox("222") Dim strData As String strData = String.Empty tcpClient.GetData(strData) txtOutput.Text = strData End Sub End Class ----------------------------------- I would highly appreciate any help, rgds, Gadi |
|
||||
|
For socket application in .Net I suggest you use the TcpClient and TcpListener classes found in System.Net.Sockets namespace.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
Uhh check out
System.Net Namespace () TcpListener Class TcpListener Class (System.Net.Sockets) TcpClient Class TcpClient Class (System.Net.Sockets) those should help you.. |
|
|||
|
a thusands thanks for the replyers.
But, it seems that the source of my problem is trying to use vb6 code in .vb application (visual studio 2008). So I downloaded a code written in .VB and I'll see if I can get it work. rgds, Gadi |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|