diff options
| author | Jay Sorg <jay.sorg@gmail.com> | 2010-10-19 21:23:13 -0700 |
|---|---|---|
| committer | Jay Sorg <jay.sorg@gmail.com> | 2010-10-19 21:23:13 -0700 |
| commit | 1e8b5ea2cd2415e8c9ca2c5cb36d3d76071f8f76 (patch) | |
| tree | 7a84e9c31f653ef75e648f403d6e1b8e1a658d9c /common/os_calls.c | |
| parent | bb7898419fea4648d7038ff78037df24a271b491 (diff) | |
| download | xrdp-proprietary-1e8b5ea2cd2415e8c9ca2c5cb36d3d76071f8f76.tar.gz xrdp-proprietary-1e8b5ea2cd2415e8c9ca2c5cb36d3d76071f8f76.zip | |
bind to specific address
Diffstat (limited to 'common/os_calls.c')
| -rw-r--r-- | common/os_calls.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index d6adf40c..913c4296 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -453,6 +453,24 @@ g_tcp_local_bind(int sck, char* port) /*****************************************************************************/ /* returns error, zero is good */ int APP_CC +g_tcp_bind_address(int sck, char* port, const char* address) +{ + struct sockaddr_in s; + + memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons((tui16)atoi(port)); + s.sin_addr.s_addr = INADDR_ANY; + if (inet_aton(address, &s.sin_addr) < 0) + { + return -1; /* bad address */ + } + return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); +} + +/*****************************************************************************/ +/* returns error, zero is good */ +int APP_CC g_tcp_listen(int sck) { return listen(sck, 2); |
