author | mjm <mjm> | 2002-12-31 12:36:06 (UTC) |
---|---|---|
committer | mjm <mjm> | 2002-12-31 12:36:06 (UTC) |
commit | d331ca1cf11e8f525665a1e5cb10f491d47c19e8 (patch) (side-by-side diff) | |
tree | 42e46b280ac5b9ce5762f0df3a09189c4912d560 /noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc | |
parent | e34eef8e2f2a36797ef980d505a99948f88a5df2 (diff) | |
download | opie-d331ca1cf11e8f525665a1e5cb10f491d47c19e8.zip opie-d331ca1cf11e8f525665a1e5cb10f491d47c19e8.tar.gz opie-d331ca1cf11e8f525665a1e5cb10f491d47c19e8.tar.bz2 |
wl_recv was more or less broken because of missing socket structure, fixed.
general cleanup.
GUI has to be updated in functions wl_setupsock and wl_recv
Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc index db6b7b8..6e26cb8 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc @@ -5,15 +5,14 @@ */ #include "wl_sock.hh" #include "wl_log.hh" /* Setup UDP Socket for incoming commands */ -int wl_setupsock(const char *host, int port) +int wl_setupsock(const char *host, int port, struct sockaddr_in saddr) { - struct sockaddr_in saddr; int sock; if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { wl_logerr("Cannot set up socket: %s", strerror(errno)); return -1; @@ -70,21 +69,23 @@ int wl_send(const char *host, int port, const char *string, ...) wl_logerr("Cannot close socket: %s", strerror(errno)); return 1; } /* Check for new messages on commsock */ -int wl_recv(int *sock, char *out, int maxlen) +int wl_recv(int *sock, struct sockaddr_in cliaddr, char *out, int maxlen) { - struct sockaddr_in *cliaddr; socklen_t len = sizeof(struct sockaddr); char retval[3]; memset(out, 0, maxlen); - if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)cliaddr, &len) < 0) + if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)&cliaddr, &len) < 0) + { + wl_logerr("Cannot receive from socket: %s", strerror(errno)); return -1; + } /* Get packet type and return it */ memset(retval, 0, sizeof(retval)); memcpy(retval, out, 2); return atoi(retval); |