[Ace-users] A newbie question

erbilkonuk erbilkonuk at gmail.com
Sun Dec 9 01:30:33 CST 2007


Has anyone got the idea why the following server code does not create
a socket with port assigned 1234. I checked with netstat that port was
not created or not. I am very new to ACE and I wish to learn it.


#include "stdafx.h"
#include "ace/INET_Addr.h"
#include "ace/SOCK_Acceptor.h"
#include "ace/SOCK_Stream.h"

int _tmain(int argc, _TCHAR* argv[])
{
	ACE_INET_Addr server_addr;
	ACE_SOCK_Acceptor acceptor;
	ACE_SOCK_Stream peer;

	if (server_addr.set(1234) == -1) return 1;
	if (acceptor.open (server_addr) == 1) return 1;

	char buf[20];

	while(true)
	{
		acceptor.accept(peer);
		peer.disable(ACE_NONBLOCK);
		for(ssize_t n; (n=peer.recv(buf, sizeof buf)) > 0;)
			ACE::write_n(ACE_STDOUT, buf, n);
 	}
	return 0;
}




Many thanks


More information about the Ace-users mailing list