Hello I have the following problem
I try to connect a client with a server using the Socket class. The server receives data but something wrong or <bad Ptr>. When the server responses Int Invalid_Password The client receives the right data.
CODE:
struct ServerLogin
{
Str sUserName;
Str sServerPassword;
};
SERVER:
INIT:
Int iPort = Convert::ToInt(options.sPort);
socket.createUdp();
socket.bind(SockAddr().setServer(iPort));
socket.block(false);
UPDATE:
for(SockAddr addr;
{
ServerLogin loginRequest;
Int rcv=socket.receive(addr,&loginRequest,SIZE(loginRequest));
if( rcv<0)break;
Client *c=NULL;
REPA(clients)if(clients[i].address==addr){c=&clients[i]; break;} // check if it's already stored on the list
if(!c) // if not found in add it
login(&addr, &loginRequest, c);
}
CLIENT:
ServerLogin loginRequest;
loginRequest.sServerPassword = sServerPassword;
loginRequest.sUserName = sUserName;
Int iPort = Convert::ToInt(sServerPort);
serverAddress.ip(sServerIp);
serverAddress.port(iPort);
Int iConnectionState = CONN_INVALID;
socket.createUdp();
socket.connect(serverAddress);
socket.block(false);
socket.send(serverAddress,&loginRequest,SIZE(loginRequest));
greetings Nes