Socket connection c++.net Help me please

  • Thread starter Thread starter Alisa
  • Start date Start date
A

Alisa

Please help me, I have to make socket connection between server and
more than one client on some port. Is it possibly? I make socket
between server and one client, but more then one is problem. I know
that I have to put connected clients in some arraylist but how to
accept them, and how to communicate ith them. Sorry on my English.
 
1. open a socket with some port on the server:

SOCKET sServerSocket;

SOCKADDR_IN sServerIn;

memset(&sServerIn,0,sizeof(sServerIn));

sServerIn.sin_family=AF_INET;

sServerIn.sin_port=htons(hPortNumber);

sServerIn.sin_addr.s_addr=htonl(INADDR_ANY);

//open server-side socket

sServerIn=socket(AF_INET,SOCK_STREAM,0);

bind(sServerSocket,(LPSOCKADDR)&sServerIn,sizeof(sServerIn))

2. declare an array of client sockets, and loop through the array, for each
client socket:

SOCKET sClientSocket[nCount];

SOCKADDR sClientSocketAddress[nCount]

for (int i=0; i<nCount; i++)

{

sClientSocket=accept(sServerSocket, &sClientSocketAddress,
&nLength);

};



3. Now you should be able to connect to multiple clients.



J.W.

Alisa said:
Please help me, I have to make socket connection between server and
more than one client on some port. Is it possibly? I make socket
between server and one client, but more then one is problem. I know
that I have to put connected clients in some arraylist but how to
accept them, and how to communicate ith them. Sorry on my English.



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Back
Top