- Home /
Question by
mustang4484 · Dec 17, 2019 at 01:45 PM ·
c#serversockettcpclient
Server TCP/IP socket problem after received one message
Hi guys I've a problem with my server in tcp/ip, because after received one message doesn't work. I don't know if use a while true, and how to put it. I would like to receive more one message from client. Any suggestion?
my method()
sdk = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sdk.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8052));
sdk.Listen(10);
Socket accepted = sdk.Accept();
Buffer = new byte[accepted.SendBufferSize];
int bytesRead = accepted.Receive(Buffer);
byte[] formatted = new byte[bytesRead];
for (int i = 0; i < bytesRead; i++)
{
formatted[i] = Buffer[i];
}
Debug.Log("\t Server" + "\n");
string stradata = Encoding.ASCII.GetString(formatted);
Debug.Log("-->" + "" + stradata + "\n\n");
testo = stradata;
//sdk.Close(); tried to uncomment
//accepted.Close(); tried to uncomment
Comment
Your answer
Follow this Question
Related Questions
Custom server for online browser game. 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
TCPClient and SslStreams in WebPlayer (C#) 0 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer