| View previous topic :: View next topic |
| Author |
Message |
Didier Guest
|
Posted: Thu May 12, 2005 7:50 pm Post subject: How to know the number of the connection in using serversock |
|
|
Hello;
I 'm using a serversocket to make dialog beetween one pc and many machines;
these machines are connecting to my pc via the serversocket Object ; so I 'm
getting the informations transmitted by the method OClientRead
(Socket.ReceiveBuf etc...);
Now I 'd like to send an ack to the machine ;so I want to use
Socket->Connections[x]->SendText etc..
The problem is that I don't know hot to get the value x !
I 've tried with a fix value (0) and it's ok when I have only one machine
connected ; but whe there are many machines there are many connections so I
have to know the number of the connection
I have to tell that i 'm usin a nonblocking Servertype
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Thu May 12, 2005 7:55 pm Post subject: Re: How to know the number of the connection in using server |
|
|
Didier wrote:
| Quote: | (Socket.ReceiveBuf etc...);
Now I 'd like to send an ack to the machine ;so I want to use
Socket->Connections[x]->SendText etc..
|
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
// Socket is the socket for the actual client.
// So if you want to send to this specific client use
... first read all with Socket->ReceiveBuf()
.. now send
Socket->SendBuf ( ... );
}
If you loop through the Connectiones[] array from 0 to
ServerSocket->Socket->ActiveConnectios - 1 you will find that
one of them has the value Socket.
Hans.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu May 12, 2005 8:43 pm Post subject: Re: How to know the number of the connection in using server |
|
|
"Didier" <bodinier.didier (AT) wanadoo (DOT) fr> wrote
| Quote: | I 'm getting the informations transmitted by the method OClientRead
(Socket.ReceiveBuf etc...);
Now I 'd like to send an ack to the machine ;so I want to use
Socket->Connections[x]->SendText etc..
|
If you are sending the ack from inside the OnClientRead event, then use the
same Socket parameter that you read your data from.
Gambit
|
|
| Back to top |
|
 |
|