projects
/
NeonServV5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8942135
)
some more changes for WIN32 compatibility
author
pk910
<philipp@zoelle1.de>
Sun, 2 Oct 2011 01:59:04 +0000
(
03:59
+0200)
committer
pk910
<philipp@zoelle1.de>
Sun, 2 Oct 2011 01:59:04 +0000
(
03:59
+0200)
src/ClientSocket.c
patch
|
blob
|
history
diff --git
a/src/ClientSocket.c
b/src/ClientSocket.c
index f4288f291ec6360aa1e0b532aad62746de386eab..98fefa7eedf5205024d62bc16123b6d0aa9420ce 100644
(file)
--- a/
src/ClientSocket.c
+++ b/
src/ClientSocket.c
@@
-178,7
+178,11
@@
int close_socket(struct ClientSocket *client) {
int write_socket(struct ClientSocket *client, char* msg, int len) {
if(!(client->flags & SOCKET_FLAG_CONNECTED)) return 0;
printf("[send %d] %s", len, msg);
int write_socket(struct ClientSocket *client, char* msg, int len) {
if(!(client->flags & SOCKET_FLAG_CONNECTED)) return 0;
printf("[send %d] %s", len, msg);
+ #ifdef WIN32
+ send(client->sock, msg, len, 0);
+ #else
write(client->sock, msg, len);
write(client->sock, msg, len);
+ #endif
client->traffic_out += len;
return 1;
}
client->traffic_out += len;
return 1;
}
@@
-204,7
+208,11
@@
void socket_loop(int timeout_seconds) {
for (sock = sockets->data; sock; sock = sock->next) {
if((sock->flags & SOCKET_FLAG_CONNECTED) && FD_ISSET(sock->sock, &fds)) {
if(sock->bufferpos != 0) {
for (sock = sockets->data; sock; sock = sock->next) {
if((sock->flags & SOCKET_FLAG_CONNECTED) && FD_ISSET(sock->sock, &fds)) {
if(sock->bufferpos != 0) {
+ #ifdef WIN32
+ bytes = recv(sock->sock, buffer, sizeof(buffer), 0);
+ #else
bytes = read(sock->sock, buffer, sizeof(buffer));
bytes = read(sock->sock, buffer, sizeof(buffer));
+ #endif
if(bytes > 0) {
for(i = 0; i < bytes; i++) {
if(sock->bufferpos + i == BUF_SIZ*2) break; //buffer overflow
if(bytes > 0) {
for(i = 0; i < bytes; i++) {
if(sock->bufferpos + i == BUF_SIZ*2) break; //buffer overflow
@@
-213,7
+221,11
@@
void socket_loop(int timeout_seconds) {
sock->bufferpos += i;
}
} else {
sock->bufferpos += i;
}
} else {
+ #ifdef WIN32
+ bytes = recv(sock->sock, sock->buffer, sizeof(sock->buffer), 0);
+ #else
bytes = read(sock->sock, sock->buffer, sizeof(sock->buffer));
bytes = read(sock->sock, sock->buffer, sizeof(sock->buffer));
+ #endif
if(bytes > 0)
sock->bufferpos = bytes;
}
if(bytes > 0)
sock->bufferpos = bytes;
}