Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Dwarfius

Pages: [1]
1
Network / Socket Selector : client crashing with 3 or more clients
« on: February 13, 2012, 04:12:08 pm »
I have a server with a socket selector and a client. They exchange data by TCP. When I run clients on the local machine (127.0.0.1, same as server) everything works fine.

However, if I run 3 or more clients from different addresses, the first client that connected crashes.

To sum things up :
Server (127.0.0.1) + Client1 (127.0.0.1) + Client2 (other ip) = OK
Server (127.0.0.1) + Client1 (127.0.0.1) + Client2 (other ip) + Client3 (other ip) = Client1 crashes

Thanks for any info regarding this.

2
Network / Socket Selector problem
« on: January 25, 2012, 05:24:50 pm »
I put a breakpoint on the Receive line in the server, but when I step over nothing happens. The Socket is neither Done, NotReady, Disconnected or Error. The program doesn't end either. I'm not sure what is going on...

3
Network / Socket Selector problem
« on: January 25, 2012, 04:25:48 pm »
I used the code on this page to make a server with sfml 2.0 : http://www.sfml-dev.org/documentation/2.0/classsf_1_1SocketSelector.php

This is where I have a problem :
Code: [Select]
// The client has sent some data, we can receive it
sf::Packet packet;
if (client.Receive(packet) == sf::Socket::Done)
{
// Extract the message and display it
std::string Message;
packet >> Message;
std::cout << "A client says : \"" << Message << "\"" << std::endl;
}


The program is stuck on the Receive method. This is the code for the client :
Code: [Select]
// Create a socket for communicating with the server
sf::TcpSocket socket;

socket.Connect("127.0.0.1", 1000);
// Send a message to the server
const char out[] = "Hi, I'm a client";
socket.Send(out, sizeof(out));

std::cout << "Message sent to the server: \"" << out << "\"" << std::endl;

// Receive an answer from the server
char buffer[1024];
std::size_t received = 0;
socket.Receive(buffer, sizeof(buffer), received);
std::cout << "The server said: " << buffer << std::endl;


I run both programs on the same computer. The client is also stuck on the Receive method.

Thanks for any help.

Pages: [1]