27.05.2016, 22:23
I don't know what is the problem but the socket is just not listening, i used udp and it worked, but then i switched to tcp and its not working
pawn Код:
Das funktioniert nicht. Ich war UDP und wechselte zu TCP und jetzt ist es nicht funktioniert.
​
C-Quellcode
Quellcode bearbeiten
#include <a_samp>
#include <socket>
​
new Socket:g_Socket;
​
main () {}
​
public OnGameModeInit()
{
g_Socket = socket_create(TCP);
if(is_socket_valid(g_Socket)) {
socket_set_max_connections(g_Socket, 10);
socket_bind(g_Socket, "192.168.1.103");
socket_listen(g_Socket, 7775);
}
return 1;
}
​
public OnGameModeExit()
{
if(is_socket_valid(g_Socket))
socket_destroy(g_Socket);
}
​
public onSocketRemoteConnect(Socket:id, remote_client[], remote_clientid)
{
printf("Incoming connection from [%d:%s]", remote_clientid, remote_client);
socket_send(id, "Welcome :)");
return 1;
}
​
public onSocketRemoteDisconnect(Socket:id, remote_clientid)
{
printf("Remote client [%d] has disconnected.", remote_clientid);
return 1;
}
​
public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len)
{
printf("Remote client [%d] has sent: %s", remote_clientid, data);
return 1;
}
​