summaryrefslogtreecommitdiff
path: root/lib/Socket.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Socket.cc')
-rw-r--r--lib/Socket.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Socket.cc b/lib/Socket.cc
index 100d434..de6f42e 100644
--- a/lib/Socket.cc
+++ b/lib/Socket.cc
@@ -2,6 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <errno.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
@@ -104,6 +105,7 @@ bool Socket::Connect(String host, int port) {
struct sockaddr_in remotesocketaddr;
if (!listening && !connected) {
+ cerr << " - Resolving '" << host << "'..." << endl;
if (!(remotehostent = gethostbyname(host.to_charp()))) {
return false;
}
@@ -111,8 +113,12 @@ bool Socket::Connect(String host, int port) {
remotesocketaddr.sin_family = AF_INET;
remotesocketaddr.sin_port = htons(port);
bcopy(remotehostent->h_addr, &remotesocketaddr.sin_addr, remotehostent->h_length);
- if(connect(GetHandle(), (struct sockaddr *)&remotesocketaddr, sizeof(remotesocketaddr)) < 0) {
+ cerr << " - Connecting to port " << port << " ..." << endl;
+ if (!connect(GetHandle(), (struct sockaddr *)&remotesocketaddr, sizeof(remotesocketaddr))) {
+ cerr << " - Connected." << endl;
connected = true;
+ } else {
+ cerr << " - Error connecting: " << strerror(errno) << endl;
}
}
return connected;