summaryrefslogtreecommitdiff
path: root/src/common/socket.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-17 13:23:34 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-17 13:23:34 +0000
commit3a4984a967675b1fd10c84730994bf08766c639d (patch)
tree00be3127a35d41ecbf1cb8f3b56922cd3575f36b /src/common/socket.c
parent1110866d367cb7a158e0b4c9dc2a16e15d3ca90d (diff)
downloadhercules-3a4984a967675b1fd10c84730994bf08766c639d.tar.gz
hercules-3a4984a967675b1fd10c84730994bf08766c639d.tar.bz2
hercules-3a4984a967675b1fd10c84730994bf08766c639d.tar.xz
hercules-3a4984a967675b1fd10c84730994bf08766c639d.zip
* Added flag.server to indicate interserver sockets
- replaces the previous way (setting 'client_addr' to 0) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11930 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/socket.c')
-rw-r--r--src/common/socket.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index 83c2dc7fd..b1c564034 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -282,7 +282,7 @@ void set_eof(int fd)
// Add this socket to the shortlist for eof handling.
send_shortlist_add_fd(fd);
#endif
- session[fd]->eof = 1;
+ session[fd]->flag.eof = 1;
}
}
@@ -460,15 +460,15 @@ int make_listen_bind(uint32 ip, uint16 port)
sFD_SET(fd, &readfds);
create_session(fd, connect_client, null_send, null_parse);
+ session[fd]->client_addr = 0; // just listens
session[fd]->rdata_tick = 0; // disable timeouts on this socket
- session[fd]->client_addr = 0;
return fd;
}
int make_connection(uint32 ip, uint16 port)
{
- struct sockaddr_in server_address;
+ struct sockaddr_in remote_address;
int fd;
int result;
@@ -493,13 +493,13 @@ int make_connection(uint32 ip, uint16 port)
setsocketopts(fd);
- server_address.sin_family = AF_INET;
- server_address.sin_addr.s_addr = htonl(ip);
- server_address.sin_port = htons(port);
+ remote_address.sin_family = AF_INET;
+ remote_address.sin_addr.s_addr = htonl(ip);
+ remote_address.sin_port = htons(port);
ShowStatus("Connecting to %d.%d.%d.%d:%i\n", CONVIP(ip), port);
- result = sConnect(fd, (struct sockaddr *)(&server_address), sizeof(struct sockaddr_in));
+ result = sConnect(fd, (struct sockaddr *)(&remote_address), sizeof(struct sockaddr_in));
if( result == SOCKET_ERROR ) {
ShowError("make_connection: connect failed (socket #%d, code %d)!\n", fd, sErrno);
do_close(fd);
@@ -512,7 +512,7 @@ int make_connection(uint32 ip, uint16 port)
sFD_SET(fd,&readfds);
create_session(fd, recv_to_fifo, send_from_fifo, default_func_parse);
- session[fd]->client_addr = 0;
+ session[fd]->client_addr = ntohl(remote_address.sin_addr.s_addr);
return fd;
}
@@ -1252,7 +1252,7 @@ bool session_isValid(int fd)
bool session_isActive(int fd)
{
- return ( session_isValid(fd) && !session[fd]->eof );
+ return ( session_isValid(fd) && !session[fd]->flag.eof );
}
// Resolves hostname into a numeric ip.
@@ -1327,12 +1327,12 @@ void send_shortlist_do_sends()
// If it's been marked as eof, call the parse func on it so that
// the socket will be immediately closed.
- if( session[fd]->eof )
+ if( session[fd]->flag.eof )
session[fd]->func_parse(fd);
// If the session still exists, is not eof and has things left to
// be sent from it we'll keep it in the shortlist.
- if( session[fd] && !session[fd]->eof && session[fd]->wdata_size )
+ if( session[fd] && !session[fd]->flag.eof && session[fd]->wdata_size )
{
send_shortlist_set[fd/32] |= 1<<(fd%32);
++i;