Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by tolga ( 14 years ago )
srv = tcpserver(port,max_conn,buffer_count); // you dont need bany buffer for server for ordinary jobs.
while(true)
{

 cli = tcpselectsocket(srv,1); // 1 means you want 1 buffer for new accepted socket
 int state = tcpselectstate(srv);

 if( state == 1 )
 {
  // new connection accepted.
  // now you can insert cli to your client list
 }
 else if( state == 2 )
 {
  //a package recieved from cli

  //get that data to buffer
  //bufferindex starts from 0.
  //So if you want to use first buffer, you should write 0. for second, write 1 etc.

  tcprecvbuffer(cli,0);

  //and parse data

  n1 = frombuffer_int(cli,0);
  n2 = frombuffer_short(cli,0);
  n3 = frombuffer_string(cli,0);
 }

}

 

Revise this Paste

Your Name: Code Language: