[Ace-users] A newbie question

kun niu haoniukun at gmail.com
Sun Dec 9 08:03:24 CST 2007


On 12月9日, 下午3时30分, erbilkonuk <erbilko... at gmail.com> wrote:
> 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

On my linux box, it's really created.
How did you check with netstat?


More information about the Ace-users mailing list