Original Post
Hey, we are currently programming a async socket connection with C#. I have a quick question. The socket doesn't always seem to be sending the data right away. So my question is, how do i have to initialise the socket to make sure that whenever i want to send a string, no matter how small, that it sends it right away. This is currently how we do it: Small socket class:
public class SocketPacket
{
// Constructor neemt een socket en een client nummer
public SocketPacket(System.Net.Sockets.Socket socket, int clientNumber)
{
m_currentSocket = socket;
m_clientNumber = clientNumber;
}
public System.Net.Sockets.Socket m_currentSocket;
public int m_clientNumber;
// Buffer om de data op te slaan die gestuurd wordt door de client.
public byte[] dataBuffer = new byte[1024];
}
And this is how we initialise the socket:
m_mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
And this is how i currently send it:
// Convert de data naar een byte array
byte[] byData = System.Text.Encoding.ASCII.GetBytes(msg);
Socket workerSocket = (Socket)m_workerSocketList[clientNumber - 1];
workerSocket.Send(byData);
This is the server part. Which is continously sending data. But i'm not sure if it's building up data first before sending, or if it's sending data right away. And that is what we want. It should send strings right away.