[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [3002] Refactoring for the socket assignment operator.
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [3002] Refactoring for the socket assignment operator. |
Date: |
Sun, 15 Feb 2009 12:49:50 +0000 |
Revision: 3002
http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3002
Author: gscrivano
Date: 2009-02-15 12:49:50 +0000 (Sun, 15 Feb 2009)
Log Message:
-----------
Refactoring for the socket assignment operator.
Modified Paths:
--------------
trunk/myserver/include/base/socket/socket.h
trunk/myserver/src/base/socket/socket.cpp
Modified: trunk/myserver/include/base/socket/socket.h
===================================================================
--- trunk/myserver/include/base/socket/socket.h 2009-02-13 23:01:33 UTC (rev
3001)
+++ trunk/myserver/include/base/socket/socket.h 2009-02-15 12:49:50 UTC (rev
3002)
@@ -1,7 +1,7 @@
/* -*- mode: c++ -*- */
/*
MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
@@ -52,9 +52,9 @@
#endif
#ifdef INET6_ADDRSTRLEN
-#define MAX_IP_STRING_LEN INET6_ADDRSTRLEN
+#define MAX_IP_STRING_LEN INET6_ADDRSTRLEN
#else
-#define MAX_IP_STRING_LEN 32
+#define MAX_IP_STRING_LEN 32
#endif
typedef struct sockaddr_storage MYSERVER_SOCKADDR_STORAGE;
@@ -67,39 +67,39 @@
public:
static int startupSocketLib ();
- void setServerSocket(Socket*);
- Socket* getServerSocket();
+ void setServerSocket(Socket*);
+ Socket* getServerSocket();
- static void stopBlockingOperations(bool);
- virtual FileHandle getHandle();
- void setHandle(FileHandle);
- static MYSERVER_HOSTENT *gethostbyaddr(char* addr, int len, int type);
- static MYSERVER_HOSTENT *gethostbyname(const char*);
- static int gethostname(char*, int);
- int socket(int, int, int);
- int bind(MYSERVER_SOCKADDR*, int);
- int listen(int);
- Socket();
- Socket(Socket*);
- Socket(FileHandle);
- Socket accept(MYSERVER_SOCKADDR*, int*);
- int setsockopt(int,int, const char*,int);
+ static void stopBlockingOperations(bool);
+ virtual FileHandle getHandle();
+ void setHandle(FileHandle);
+ static MYSERVER_HOSTENT *gethostbyaddr(char* addr, int len, int type);
+ static MYSERVER_HOSTENT *gethostbyname(const char*);
+ static int gethostname(char*, int);
+ int socket(int, int, int);
+ int bind(MYSERVER_SOCKADDR*, int);
+ int listen(int);
+ Socket();
+ Socket(Socket*);
+ Socket(FileHandle);
+ Socket accept(MYSERVER_SOCKADDR*, int*);
+ int setsockopt(int,int, const char*,int);
- virtual int connect(MYSERVER_SOCKADDR*, int);
- virtual int close();
- virtual int shutdown(int how);
- virtual int recv(char*, int, int, u_long);
- virtual int recv(char*, int, int);
- virtual u_long bytesToRead();
+ virtual int connect(MYSERVER_SOCKADDR*, int);
+ virtual int close();
+ virtual int shutdown(int how);
+ virtual int recv(char*, int, int, u_long);
+ virtual int recv(char*, int, int);
+ virtual u_long bytesToRead();
- int ioctlsocket(long, unsigned long*);
- int send(const char*, int, int);
- int connect(const char* host, u_short port);
- int operator==(Socket);
- int operator=(Socket);
- int getsockname(MYSERVER_SOCKADDR*,int*);
+ int ioctlsocket(long, unsigned long*);
+ int send(const char*, int, int);
+ int connect(const char* host, u_short port);
+ int operator==(Socket);
+ int operator=(Socket);
+ int getsockname(MYSERVER_SOCKADDR*,int*);
int setNonBlocking(int);
- virtual int dataOnRead(int sec = 0, int usec = 500);
+ virtual int dataOnRead(int sec = 0, int usec = 500);
u_long getThrottling();
void setThrottling(u_long);
@@ -110,19 +110,19 @@
protected:
#ifdef WIN32
- SOCKET socketHandle;
+ SOCKET socketHandle;
#else
- FileHandle socketHandle;
+ FileHandle socketHandle;
#endif
- /*! Pointer to the socket that has accepted this connection. */
- Socket *serverSocket;
+ /*! Pointer to the socket that has accepted this connection. */
+ Socket *serverSocket;
/*! Send throttling rate. */
u_long throttlingRate;
- /*! Stop the sockets system. */
- static bool denyBlockingOperations;
+ /*! Stop the sockets system. */
+ static bool denyBlockingOperations;
virtual int rawSend(const char* buffer, int len, int flags);
};
Modified: trunk/myserver/src/base/socket/socket.cpp
===================================================================
--- trunk/myserver/src/base/socket/socket.cpp 2009-02-13 23:01:33 UTC (rev
3001)
+++ trunk/myserver/src/base/socket/socket.cpp 2009-02-15 12:49:50 UTC (rev
3002)
@@ -1,6 +1,6 @@
/*
MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
@@ -88,9 +88,10 @@
*/
int Socket::operator=(Socket s)
{
- /*! Do a raw memory copy. */
- memcpy(this, &s, sizeof(s));
- return 1;
+ socketHandle = s.socketHandle;
+ serverSocket = s.serverSocket;
+ throttlingRate = s.throttlingRate;
+ return 0;
}
/*!
*Create the socket.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [3002] Refactoring for the socket assignment operator.,
Giuseppe Scrivano <=