Hi there,
Anything will help.
I have running server on computer and want to connect from some clients.
Server:
memset(&hints, 0, sizeof(hints));
hints.ai_family = domain;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo("localhost", "8300", &hints, &res0);
if (error)
{
return false;
}
for (res = res0; res; res = res->ai_next)
{
socket_d = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
int result = bind(socket_desc, (const sockaddr *) res->ai_addr, res->ai_addrlen);
}
And I want to connect from some client:
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNKNOWN;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo("195.113.21.133", "8300", &hints, &res0);
if (error)
{
return false;
}
for (res = res0; res; res = res->ai_next)
{
socket_d = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
int result = connect(socket_d, res->ai_addr, res->ai_addrlen);
}
When I put "localhost" in getaddrinfo everything is fine. But when I tried to put some other IP, it crashes. IP is correct, both computers are on same network.
THX for any advice!