summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/RNBSocket.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-04-01 00:29:43 +0000
committerGreg Clayton <gclayton@apple.com>2011-04-01 00:29:43 +0000
commit95bf0fd3abcefce429f40f875f0f9ae3b0deed9e (patch)
treebd49ef5193260ddda29ba21320f980d3a5f9c6f5 /lldb/tools/debugserver/source/RNBSocket.cpp
parentea6b81a2ad3d3757c2d748ccab28c0c661cc38ed (diff)
downloadbcm5719-llvm-95bf0fd3abcefce429f40f875f0f9ae3b0deed9e.tar.gz
bcm5719-llvm-95bf0fd3abcefce429f40f875f0f9ae3b0deed9e.zip
Added the ability to get a broadcaster event name for a given broadcaster
event. Modified the ProcessInfo structure to contain all process arguments. Using the new function calls on MacOSX allows us to see the full process name, not just the first 16 characters. Added a new platform command: "platform process info <pid> [<pid> <pid> ...]" that can be used to get detailed information for a process including all arguments, user and group info and more. llvm-svn: 128694
Diffstat (limited to 'lldb/tools/debugserver/source/RNBSocket.cpp')
-rw-r--r--lldb/tools/debugserver/source/RNBSocket.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/lldb/tools/debugserver/source/RNBSocket.cpp b/lldb/tools/debugserver/source/RNBSocket.cpp
index 08fa4ac79ce..139a4150adf 100644
--- a/lldb/tools/debugserver/source/RNBSocket.cpp
+++ b/lldb/tools/debugserver/source/RNBSocket.cpp
@@ -12,8 +12,10 @@
//===----------------------------------------------------------------------===//
#include "RNBSocket.h"
+#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
+#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <termios.h>
@@ -106,6 +108,55 @@ RNBSocket::Listen (in_port_t listen_port_num)
return rnb_success;
}
+rnb_err_t
+RNBSocket::Connect (const char *host, uint16_t port)
+{
+ Disconnect (false);
+
+ // Create the socket
+ m_conn_port = ::socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (m_conn_port == -1)
+ return rnb_err;
+
+ // Enable local address reuse
+ SetSocketOption (m_conn_port, SOL_SOCKET, SO_REUSEADDR, 1);
+
+ struct sockaddr_in sa;
+ ::memset (&sa, 0, sizeof (sa));
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons (port);
+
+ if (host == NULL)
+ host = "localhost";
+
+ int inet_pton_result = ::inet_pton (AF_INET, host, &sa.sin_addr);
+
+ if (inet_pton_result <= 0)
+ {
+ struct hostent *host_entry = gethostbyname (host);
+ if (host_entry)
+ {
+ std::string host_str (::inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list));
+ inet_pton_result = ::inet_pton (AF_INET, host_str.c_str(), &sa.sin_addr);
+ if (inet_pton_result <= 0)
+ {
+ Disconnect (false);
+ return rnb_err;
+ }
+ }
+ }
+
+ if (-1 == ::connect (m_conn_port, (const struct sockaddr *)&sa, sizeof(sa)))
+ {
+ Disconnect (false);
+ return rnb_err;
+ }
+
+ // Keep our TCP packets coming without any delays.
+ SetSocketOption (m_conn_port, IPPROTO_TCP, TCP_NODELAY, 1);
+ return rnb_success;
+}
+
#if defined (__arm__)
rnb_err_t
RNBSocket::ConnectToService()
OpenPOWER on IntegriCloud