First of all, SendTo
is only used for UDP sockets. In the code snippet above, you are opening a TCP socket. SendTo
won't work with a TCP socket. Try it with a UDP socket and see if it works. Bear in mind that the maximum practical size of a UDP packet is 65,507 bytes. Generally, you want to keep UDP packets small to avoid fragmentation by the various network elements involved with their transmission.
EDIT:
Use TcpClient to make your life easier.
Int32 port = 13293;
String host = "somehost.com";
TcpClient tcpClient = new TcpClient(host, port);
Byte[] data = System.Text.Encoding.ASCII.GetBytes("your message to send");
NetworkStream stream = tcpClient.GetStream();
stream.Write(data, 0, data.Length);