ok i figured out that in visual studio .NET that i had to program my own windows socket so i did a search on googlie and found a tut. the only problem is that when i open it up and run it, it will just close after being open for maybe a second or two. im tryin to make a chat program for multiple users. XP. thanks for any help.



Imports System.Net.Sockets
Imports System.Net
Imports System.Text
Imports System.Net.DnsPermissionAttribute
Imports System.Security.Permissions
Module Module1

'DnsPermissionAttribute specifies permission to request information from Domain Name Servers.
<DnsPermissionAttribute(SecurityAction.Demand, Unrestricted:=True)> Class CTestTCPServer
Shared Sub Main()
'Server must be on the same port that the client is connected on.
Const portNumber As Integer = 8000

'"Localhost" string is used when the client and the listener are on the same computer.
'If the server is listening at a computer that is different from the client, then provide the host name of the computer
'where the server is listening.
'Dim tcpListener As New TcpListener(CType(Dns.Resolve("DDE_Chatting").AddressList(0),192.168.35.53), 8000)
'Comment the previous line and uncomment the following line if you are using Visual Basic .NET (2003).
Dim tcpListener As New TcpListener(8000)
tcpListener.Start()
Console.WriteLine("TCP Server is up and waiting for Client connection...")
Try

''Accept the pending client connection and return a TcpClient for communication.
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Console.WriteLine("Connection accepted.")
' Get the data stream.
Dim networkStream As NetworkStream = tcpClient.GetStream()
' Read the data stream into a byte array.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Return the data received from the client to the console.
Dim clientdata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine(("Client sent: " + clientdata))
Dim responseString As String = "Successfully connected to TCP server."
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Console.WriteLine(("Message Sent by TCP Server /> : " + responseString))
'Close TcpListener and TcpClient.
tcpClient.Close()
tcpListener.Stop()
Console.WriteLine("Exit")
Console.ReadLine()
Catch e As Exception
Console.WriteLine(e.ToString())
Console.ReadLine()
End Try
End Sub
End Class
Sub Main()

End Sub

End Module


i dont know if there is any special format to put code in so my bad if its wrong.