c++ socket connection not working when not using ip


John

I am trying to connect to my Java server with my C++ client via dns.

So when I enter the dns name instead of my localip, it won't connect. code: invalid

    sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = inet_addr("blalblalb.no-ip.com");
    addr.sin_port = htons(4444);

However, when I type the ip address of the dns, it works. Code: WORKS

    sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = inet_addr("174.554.xx.xxx");
    addr.sin_port = htons(4444);

why is that?

Christopher

inet_addr()Addresses that should only be represented by numbers and periods.

If you want to use a hostname, use it instead. The link to the man page contains a Linux example ( here a Windows example ).getaddrinfo()

Note that inet_addr()only IPv4 addresses are handled and are not compatible with the IPv6 format. You may consider further verification.inet_ptron()

Related


c++ socket connection not working when not using ip

John I am trying to connect to my Java server with my C++ client via dns. So when I enter the dns name instead of my localip, it won't connect. code: invalid sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("blalblalb.n

c++ socket connection not working when not using ip

John I am trying to connect to my Java server with my C++ client via dns. So when I type the dns name instead of my localip it won't connect. code: invalid sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("blalblalb.no-

c++ socket connection not working when not using ip

John I am trying to connect to my Java server with my C++ client via dns. So when I type the dns name instead of my localip it won't connect. code: invalid sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("blalblalb.no-

Connection refused when using UDP socket in loop

Encoder Consider the following MWE class , foowhich has a sendmember function that allows sending a string over UDP to a loopback address on port 1337: head File:foo.h #include <boost/asio.hpp> class foo { public: foo(); // Constructor. void send(std::st

Connection refused when using UDP socket in loop

Encoder Consider the following MWE class , foowhich has a sendmember function that allows sending a string over UDP to a loopback address on port 1337: head File:foo.h #include <boost/asio.hpp> class foo { public: foo(); // Constructor. void send(std::st

Secure socket connection using C++

Dziaji I am trying to get an SSL/TLS connection to work in Windows. Right now, I'm using Schannel, but I'm not sure if this is the correct approach. Here is my code. InitializeSecurityContextA() function throws exception #include "windows.h" #pragma comment(li

Connection refused when using IP but not when using localhost

David Antello I have deployed my web application in my apache 9 server. I have configured the server following the internet guide and it works fine if I use this link: http://localhost:8080/ejercicios-programacion/ this redirects me to https://localhost:8443/

Connection refused when using IP but not when using localhost

David Antello I have deployed my web application in my apache 9 server. I have configured the server following the internet guide and it works fine if I use this link: http://localhost:8080/ejercicios-programacion/ this redirects me to https://localhost:8443/

Mikrotik TCP/IP socket connection

Altair I need to know if it is possible to connect a Mikrotik script to a TCP/IP Websocket to transfer some data, eg using a PC or PLC (which can provide a server socket). Thanks for any answer. dash1121 You can /tool fetchdownload files from remote servers us

Mikrotik TCP/IP socket connection

Altair I need to know if it is possible to connect a Mikrotik script to a TCP/IP Websocket to transfer some data, eg using a PC or PLC (which can provide a server socket). Thanks for any answer. dash1121 You can /tool fetchdownload files from remote servers us

Socket connection on Java, specifying IP

Jarbano I am developing a program where multiple clients need to interact with a remote server. I've tested it locally and everything works fine (more on that later), but I don't know how to set the remote IP. I read Socket's API and InetAddress's API. Is this

Socket connection on Java, specifying IP

Jarbano I am developing a program where multiple clients need to interact with a remote server. I've tested it locally and everything works fine (more on that later), but I don't know how to set the remote IP. I read Socket's API and InetAddress's API. Is this

C# delegate using socket not working

My sky I am writing a chat program using sockets in C# (Winform). Here is a part of my source code: ( left and center functions are the same as in VB and will return a string) server: Socket Serv; List<Socket> ClnSocket = new List<Socket>(); Socket socket; Thr

C# delegate using socket not working

My sky I am writing a chat program using sockets in C# (Winform). Here is a part of my source code: ( left and center functions are the same as in VB and will return a string) server: Socket Serv; List<Socket> ClnSocket = new List<Socket>(); Socket socket; Thr

MySQL user permissions not working when using IP

so lucky I have current setup: SVR01: Ubuntu Trusty with Xen VM01: IP: 192.168.0.10 Ubuntu Trusty with Apache2 + php modules VM02: IP: 192.168.0.11 Ubuntu Trusty with mysql server When I try to connect to mysql on VM02 from VM01 (Apache server), I get "Access

MySQL user permissions not working when using IP

so lucky I have current setup: SVR01: Ubuntu Trusty with Xen VM01: IP: 192.168.0.10 Ubuntu Trusty with Apache2 + php modules VM02: IP: 192.168.0.11 Ubuntu Trusty with mysql server When I try to connect to mysql on VM02 from VM01 (Apache server), I get "Access

MySQL user permissions not working when using IP

so lucky I have current setup: SVR01: Ubuntu Trusty with Xen VM01: IP: 192.168.0.10 Ubuntu Trusty with Apache2 + php modules VM02: IP: 192.168.0.11 Ubuntu Trusty with mysql server When I try to connect to mysql on VM02 from VM01 (Apache server), I get "Access

Internet stops working when using static IP

Phoenix I'm running Windows 8.1 and I'm trying to configure a static IP address for server hosting. Without using a static IP address, my IPV4 properties are as follows: The internet and network are functioning normally. However, when I try to set a static IP

MySQL user permissions not working when using IP

so lucky I have current setup: SVR01: Ubuntu Trusty with Xen VM01: IP: 192.168.0.10 Ubuntu Trusty with Apache2 + php modules VM02: IP: 192.168.0.11 Ubuntu Trusty with mysql server When I try to connect to mysql on VM02 from VM01 (Apache server), I get "Access

Internet stops working when using static IP

Phoenix I'm running Windows 8.1 and I'm trying to configure a static IP address for server hosting. Without using a static IP address, my IPV4 properties are as follows: The internet and network are functioning normally. However, when I try to set a static IP

Detect when socket connection is disconnected C/C++ Unix

Brooks private account I know this question has been discussed several times, but I haven't managed to detect if a socket is disconnected in C/C++ on Unix. What is the solution? Thanks, Regards Brooks squirrel I'm assuming the socket might be closed by the pee

iOS connection via socket not working

username I red a tutorial on iOS socket programming. iOS web tutorial . As mentioned, I started the server using a python script. I have some clients connected via telnet and everything works fine. Then, I wrote a code or an iOS app, and the problem occurred.

iOS connection via socket not working

username I red a tutorial on iOS socket programming. iOS web tutorial . As mentioned, I started the server using a python script. I have some clients connected via telnet and everything works fine. Then, I wrote a code or an iOS app, and the problem occurred.

Socket.io doesn't show connection when using phone

Wolfe So I made a server with a small party game and the idea was that people could connect their phones, get their cards through the players page, and one person (the game admin) could control which ones were ticked through the GM page. Through my browser it