i was woking on A7 7.84 pro about socket.but there is a problem that:
the socket_connect and socket_send work fine in one program.(like the example code)
but when i use it in two programs like server.c and client.c (whatever they are both runned on the same computer or in the same network) the socket_recieve() returns 0 and nothing received.
can the socket_ function run in different program?or it can only run in one program?
#include <acknex.h>
#include <default.c>
#include <d3d9.h>
STRING* l_C_Server_Address = "127.0.0.1";
var l_C_Port_Num = 1234;
TEXT* txtReceive = { flags = SHOW; }
function main()
{
level_load("");
wait(3);
if (!socket_connect(l_C_Server_Address, l_C_Port_Num, 0)) {
printf("Can't connect to GalepX!");
} else {
char input;
while(1) {
wait(1);
// receive the response
int received = socket_receive(input,str_len("d"));
if (received) {
input[received]=0;
printf(input);
// display the response
// input[received] = 0; // add '0' end mark
txt_addstring(txtReceive,input);
}
}
}
}
#include <acknex.h>
#include <default.c>
#include <d3d9.h>
STRING* l_C_Server_Address = "127.0.0.1";
var l_C_Port_Num = 1234;
TEXT* txtReceive = { flags = SHOW; }
function main()
{
level_load("");
wait(3);
if (!socket_connect(l_C_Server_Address, l_C_Port_Num, 0)) {
printf("Can't connect to GalepX!");
} else {
while(1){
socket_connect(l_C_Server_Address, l_C_Port_Num, 0);
if(key_s)socket_send(_chr("s"),str_len("s"));
if(key_d)socket_send(_chr("d"),str_len("d"));
wait(1);
}
}
}
plz hlep me have a look at what's the problem
the source code is like the attachment.