- Joined
- Mar 26, 2006
- Messages
- 603
- Reaction score
- 7
So I've been learning how to use VC++ for fun. I began playing around with sockets.
I can read 1 client, but cannot send information to a second one or check if it exists.
Basically I'm wanting the server to check how many clients are connected and allow them to interact through the server.
Could someone possibly look at what I have and point me in the right direction.
Or if you tell me what I've done wrong explain how you've fixed it.
Thanks in advance.
P.S. If someone also has anything on Connecting to MySQL could you give me a good link to read?
Code:
I can read 1 client, but cannot send information to a second one or check if it exists.
Basically I'm wanting the server to check how many clients are connected and allow them to interact through the server.
Could someone possibly look at what I have and point me in the right direction.
Or if you tell me what I've done wrong explain how you've fixed it.
Thanks in advance.
P.S. If someone also has anything on Connecting to MySQL could you give me a good link to read?
Code:
Code:
public: void server() {
IPAddress^ localAddr = IPAddress::Parse( "127.0.0.1");
Int32 port = 13000;
IPEndPoint^ ep = gcnew IPEndPoint( localAddr,port );
ipendpoints = gcnew array<IPEndPoint^>(1);
ipendpoints[0] = ep;
Socket^ server = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp );
srv = gcnew array<Socket^>(1);
srv[0] = server;
con = gcnew array<Socket^>(2);
array<Byte>^bytes = gcnew array<Byte>(256);
array<Byte>^buffer = gcnew array<Byte>(1024);
String^ data = nullptr;
String^ recieved;
srv[0]->Bind( ipendpoints[0] );
srv[0]->Listen(15);
String^ output;
data = nullptr;
Int32 i;
while(true) {
if(Socket^ client = srv[0]->Accept()) {
con[cn] = client;
cn++;
}
}
}
Last edited:


