Socket Programming
Visual Basic
I like the example from EggHeadCafe.com: VB.NET
TCP Client - Server Socket Communications
-
Dim tcpClient As New System.Net.Sockets.TcpClient()
-
'tcpClient.Connect("127.0.0.1", 8000)
-
Dim ns As NetworkStream = tcpClient.GetStream()
-
'read from socket
-
Dim byteIn(tcpClient.ReceiveBufferSize) As Byte
-
ns.Read(byteIn, 0, byteIn.Length)
-
Dim strIn As String = Encoding.ASCII.GetString(byteIn)
-
client.Text = strIn
MS Visual C++
This code come from The Code Project's example MC++
TCP server talking to MFC & MC++ TCP clients
-
CSocket s; //declare the socket
-
s.Create();
-
s.Connect("127.0.0.1",20248) // open the socket up
-
s.Send(m_text,m_text.GetLength()); // send data over socket
-
i=s.Receive(buff,16); // receive data over socket
Java
We will look at an example from Java World: Sockets
programming in Java: A tutorial