17.11.2010, 15:44
Cool, Cool
main()
{
socket_connect("mail.venturas-cnr.com", 25);
// prints: [20:13:03] [Socket] Successfully connected to: mail.venturas-cnr.com:25.
}
public OnSocketReceive(data[], address[], port)
{
printf("OnSocketReceive Called!");
// Prints: Nothing
printf(data);
// Prints: Nothing
// Should print: 220 nl.webserver.serverffs.com ESMTP Exim 4.69 Mon, 24 Jan 2011 20:06:01 +0100
new
responsecode,
message[256];
sscanf(data, "ds[256]", responsecode, message);
return 1;
}
public OnSocketConnect(address[], port) { socket_send("Sing Alleluja!"); socket_close(); return 1; }
---------- Loaded log file: "server_log.txt". ---------- SA-MP Dedicated Server ---------------------- v0.3c, ©2005-2010 SA-MP Team Server Plugins -------------- Loading plugin: sockets SA:MP Sockets Plugin BETA R2 Loaded. Loaded. Loaded 1 plugins. Started server on port: 7777, with maxplayers: 12 lanmode is ON. Filter Scripts --------------- Loaded 0 filter scripts. ---------------------------------- TruckersLife v.1.5a ---------------------------------- Number of vehicle models: 75 loadfs SocketClient [Socket] Successfully connected to: 192.168.1.100:7788. Connected to Server Filterscript 'SocketClient.amx' loaded. Incoming connection: 127.0.0.1:56580 [join] Chicken has joined the server (0:127.0.0.1) [user] Account file loaded for Chicken(0) [chat] [Chicken]: hi [Socket] Debug: Function socket_send sent "Chicken says:hi". [user] Account file saved for Chicken(0) [part] Chicken has left the server (0:1) Incoming connection: 127.0.0.1:63333 [join] Chicken has joined the server (0:127.0.0.1) [user] Account file loaded for Chicken(0) [chat] [Chicken]: test [Socket] Debug: Function socket_send sent "Chicken says:test". [chat] [Chicken]: test [Socket] Debug: Function socket_send sent "Chicken says:test". [user] Account file saved for Chicken(0) [part] Chicken has left the server (0:1)
#include <a_samp>
#include <sockets>
#define PORT 7788
#define COLOR_LINK 0xFFFAFAAA
forward OnSocketRecieve(data[], address[]);
public OnSocketConnect(address[])
{
if ( strcmp(address, "127.0.0.1") != 0 ) // not a local connection!
{
socket_close();
print("[socket] Client tried to connect to itself! Connection rejected!");
}
return 1;
}
public OnSocketRecieve(data[], address[])
{
new string[160];
format(string, sizeof(string), "[%s] %s", address, data);
print(string);
SendClientMessageToAll(COLOR_LINK, string);
return 1;
}
public OnFilterScriptInit()
{
socket_connect("192.168.1.100", PORT);
print("Connected to Server");
return 1;
}
public OnPlayerText(playerid, text[])
{
new string[160];
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(string, sizeof(string), "%s says:%s", Name, text);
socket_send(string);
return 1;
}
---------- Loaded log file: "server_log.txt". ---------- SA-MP Dedicated Server ---------------------- v0.3c, ©2005-2010 SA-MP Team Server Plugins -------------- Loading plugin: sockets SA:MP Sockets Plugin BETA R2 Loaded. Loaded. Loaded 1 plugins. Started server on port: 7777, with maxplayers: 12 lanmode is ON. Filter Scripts --------------- Loading filter script 'SocketServer.amx'... Loaded 1 filter scripts. ---------------------------------- TruckersLife v.1.5a ---------------------------------- Number of vehicle models: 75 [Socket] Started listening on port 7788. [Socket] Incomming connection from: 192.168.1.144:60613. Incoming connection: 192.168.1.144:63334 [join] Chicken has joined the server (0:192.168.1.144) [user] Account file loaded for Chicken(0) [chat] [Chicken]: test [Socket] Debug: Function socket_send sent "Chicken says:test". [user] Account file saved for Chicken(0) [part] Chicken has left the server (0:1)
#include <a_samp>
#include <sockets>
#define PORT 7788
#define COLOR_LINK 0xFFFAFAAA
forward OnSocketRecieve(data[], address[]);
main()
{
print("\n----------------------------------");
print(" Wormhole test loaded [SERVER]\n");
print("----------------------------------\n");
}
public OnSocketConnect(address[])
{
if ( strcmp(address, "127.0.0.1") != 0 ) // not a local connection!
{
socket_close();
print("[socket] Server tried to connect to itself! Connection rejected!");
}
return 1;
}
public OnSocketRecieve(data[], address[])
{
new string[160];
format(string, sizeof(string), "[%s] %s", address, data);
print(string);
SendClientMessageToAll(COLOR_LINK, string);
return 1;
}
public OnFilterScriptInit()
{
socket_startlistening(PORT);
return 1;
}
public OnPlayerText(playerid, text[])
{
new string[160];
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(string, sizeof(string), "%s says:%s", Name, text);
socket_send(string);
return 1;
}