1
Since sockets are a common choice for high-performance communication between applications of different platforms, my doubt is, that makes them also multilingual?
Bringing the situation to my context, what could be the reason why a server algorithm developed in C did not communicate with a client developed in another language?
There is, in this case, some specific configuration in the server algorithm so that it is able to recognize only communication requests from clients developed in the same language?
I developed the C server [on Linux] and the client is a serial redirector [on Windows].
I provide below the server algorithm I am using:
Server. c
The code has been tested and works with a client *(. c)
int main(void) { int socket_serv, socket_cli; struct sockaddr_in addr_server; //Cria o socket servidor socket_serv = socket(AF_INET, SOCK_STREAM, 0); setsockopt(socket_serv, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof(int)); if (socket_serv == -1) { perror ("Nao foi possivel criar o servidor!\n"); return -1; } //Prepara a estrutura do endereco do socket servidor addr_server.sin_family = AF_INET; addr_server.sin_addr.s_addr = inet_addr("192.168.15.15");//INADDR_ANY; addr_server.sin_port = htons(2000); //Bind if (bind (socket_serv, (struct sockaddr *)&addr_server, sizeof(addr_server)) < 0) { perror ("Falhou o bind no servidor\n"); return -2; } //Listen listen (socket_serv, 1); //Aceita uma conexão de um cliente puts ("Aguardando cliente...\n"); while ( (socket_cli = accept (socket_serv, 0, 0)) ) { puts ("Cliente conectado!\n"); .... } return 0;}
I appreciate the reply @zentrunix. Would you be kind enough to try to explain to me why my server program is not able to recognize the client I am using but a client developed in the same language? Any suggestions? Thank you!
– Caio de Paula Silva
Why your client is probably not communicating properly in another language. A more appropriate question than the one you asked could be: "why is this socket client in X language can’t communicate with this other server in Y language" - and the code of both, of course (a minimum code that would only show the connection to who will answer find the error). I agree that 'knowing that it is possible' is a prerequisite for this other question - so I suggest accepting this answer, and creating another more complete question
– jsbueno
Caio de Paula Silva: as my colleague @jsbueno said, create a small test client program, and if you have problems post here the source of the client and the problem that occurred
– zentrunix
I appreciate it. Too bad I don’t have access to the serial redirector code I’m using as a client... It intrigues me because he has served me with another server. But not this.
– Caio de Paula Silva