hi, i'm trying to send a simple string through socket to my java socket server (i'm pretty sure the server is okay cuz i've tested it with several other tools to see of it really echos what ever you send to it though socket), but unfortunately after i get connected to the socket nothing else really happens, i can't send a socket message, the server says i'm connected but the plugin's forward for connection does not print me the string i wrote into the forward. any help? here is my code and all i want for now is a simple string to be sent only(not received):
PHP Code:
#include <sourcemod>
#include <socket>
Handle:socket = INVALID_HANDLE;
public OnPluginStart() {
// create a new tcp socket
socket = SocketCreate(SOCKET_TCP, OnSocketError);
// connect the socket
SocketConnect(socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, "localhost", 6500)
RegServerCmd("sm_ech", Ech);
}
public Action Ech(int args)
{
SocketSend(socket, "ERRRRR");
}
public OnSocketConnected(Handle:socket, any:arg) {
// socket is connected, send the http request
PrintToServer("[SOCKET] Connected.");
SocketSend(socket, "PONH");
}
public OnSocketReceive(Handle:socket, String:receiveData[], const dataSize, any:hFile) {
// receive another chunk and write it to <modfolder>/dl.htm
// we could strip the http response header here, but for example's sake we'll leave it in
PrintToServer("[SOCKET] New Data: %s", receiveData);
}
public OnSocketDisconnected(Handle:socket, any:hFile) {
// Connection: close advises the webserver to close the connection when the transfer is finished
// we're done here
PrintToServer("[SOCKET] Disconnected.");
CloseHandle(socket);
socket = INVALID_HANDLE;
}
public OnSocketError(Handle:socket, const errorType, const errorNum, any:hFile) {
// a socket error occured
PrintToServer("[SOCKET] socket error %d (errno %d)");
CloseHandle(socket);
socket = INVALID_HANDLE;
}
Any help?
__________________