#inet_ntoa returns invalid address ?

9 messages · Page 1 of 1 (latest)

open wind
#
int main() {
 Server server = (Server) {
    .ip = SERVER_IP,
    .port = SERVER_PORT,
  };
  server_init(&server);
  Playerlist* list = create_list(DEFAULT_PLR_COUNT);
  const char buff[DEFAULT_BUFF_SIZE] = {0};
  struct sockaddr_in client_addr = {0};
  client_addr.sin_family = AF_INET;
  //client_addr.sin_addr.s_addr = INADDR_ANY;
  while (1) {

    Packet p = receive_packet(&server,
        buff,
        DEFAULT_BUFF_SIZE,
        &client_addr);
    printf("cool ip is : %s\n", inet_ntoa(client_addr.sin_addr));
    //
    handle_packet(p,
        &server,
        list,
        buff,
        DEFAULT_PLR_COUNT,
        &client_addr);
    //
    sleep(1);
  }

  free(list);
  return EXIT_SUCCESS;
}

i send from my wsl machine to this socket program hosted on a vps

zealous ibexBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

open wind
#

inet_nota returns 0.0.0.0

#

but it should return the ip of my machine

open wind
#

the problem was

#

i pass the sizeof the client address

#

bty value not by reference

#

and the compiler didnt give any warnings or error

#

!solve