Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 02-01-2002, 06:11 AM
alkrun
Sarnak
 
Join Date: Jan 2002
Posts: 66
Default

net.cpp

Comment out the 'server listening' message, is sent in InitTCP now'
Code:
//	cout << "World server listening on port:" << PORT << endl;

Change the UDP port
Code:
bool NetConnection::Init()
{
	struct sockaddr_in address;
	int reuse_addr = 1;
	
	// Disgrace: for windows compile
#ifdef WIN32
	unsigned long nonblocking = 1;
	WORD version = MAKEWORD (1,1);
	WSADATA wsadata;
	WSAStartup (version, &wsadata);
#endif
	struct hostent *phostent = NULL;


  /* Setup internet address information.  
     This is used with the bind() call */
	memset((char *) &address, 0, sizeof(address));
	address.sin_family = AF_INET;
	address.sin_port = htons(PORT);
	address.sin_addr.s_addr = htonl(INADDR_ANY);
	unsigned long lAddr = INADDR_NONE;

	//GET WORLD SERVER ADDRESS
	if((lAddr = inet_addr(net.GetWorldAddress())) != INADDR_NONE){
		if((phostent = gethostbyaddr((char*)&lAddr, sizeof(unsigned long), AF_INET)) != NULL){
			memcpy ((char*)&(address.sin_addr), phostent->h_addr, phostent->h_length);
		}
	}else if((phostent = gethostbyname(net.GetWorldAddress())) != NULL){
		memcpy ((char*)&(address.sin_addr), phostent->h_addr, phostent->h_length);
	}

	/* Setting up UDP port for new clients */
	listening_socket = socket(AF_INET, SOCK_DGRAM, 0);
	if (listening_socket < 0) 
 	{
	
		return false;
	}

	// Disgrace: for windows compile
#ifndef WIN32
	setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
#else
	setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse_addr, sizeof(reuse_addr));
#endif

	if (bind(listening_socket, (struct sockaddr *) &address, sizeof(address)) < 0) 
	{
		// Disgrace: for windows compile
		#ifdef WIN32
			closesocket(listening_socket);
		#else
			close(listening_socket);
		#endif
		
		return false;
	}

	// Disgrace: for windows compile
#ifndef WIN32
	fcntl(listening_socket, F_SETFL, O_NONBLOCK);
#else
	ioctlsocket (listening_socket, FIONBIO, &nonblocking);
#endif


	return true;
}
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 12:41 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3