* UDP client
@ 2007-03-30 2:23 Alexsandro Soares
2007-03-30 11:28 ` [Caml-list] " Gerd Stolpmann
0 siblings, 1 reply; 2+ messages in thread
From: Alexsandro Soares @ 2007-03-30 2:23 UTC (permalink / raw)
To: caml-list
Hi all,
I'm working in an UDP client, but I can't figure out how to get the same behaviour, in OCaml, such as the C code below:
-----------------------------------------------------------------------------------------------
sigset_t sigmask;
sigemptyset(&sigmask);
sigaddset(&sigmask, SIGIO);
sigprocmask(SIG_BLOCK, &sigmask, NULL);
/*
* Open UDP socket.
*/
if( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){
return sock ; /* Can't open socket. */
}
if (fcntl(sockfd, F_SETOWN, getpid()) == -1) return sock;
val = fcntl(sockfd, F_GETFL, 0) ;
val |= O_NONBLOCK ;
val |= FASYNC;
fcntl(sockfd, F_SETFL, val) ;
------------------------------------------------------------------------------------
Could anyone help me?
Thanks,
Alex
__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] UDP client
2007-03-30 2:23 UDP client Alexsandro Soares
@ 2007-03-30 11:28 ` Gerd Stolpmann
0 siblings, 0 replies; 2+ messages in thread
From: Gerd Stolpmann @ 2007-03-30 11:28 UTC (permalink / raw)
To: Alexsandro Soares; +Cc: caml-list
Well, there is no binding that would allow you to do that (emitting
SIGIO when a datagram arrives). In my opinion it is better not to use
SIGIO for new code, because signals are hard to manage.
So my advice would be: Rewrite it. Use either select or threads or both
for receiving datagrams in parallel with other activities.
Gerd
Am Donnerstag, den 29.03.2007, 19:23 -0700 schrieb Alexsandro Soares:
> Hi all,
>
> I'm working in an UDP client, but I can't figure out how to get the same behaviour, in OCaml, such as the C code below:
>
> -----------------------------------------------------------------------------------------------
>
> sigset_t sigmask;
>
> sigemptyset(&sigmask);
> sigaddset(&sigmask, SIGIO);
> sigprocmask(SIG_BLOCK, &sigmask, NULL);
>
> /*
> * Open UDP socket.
> */
> if( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){
> return sock ; /* Can't open socket. */
> }
>
> if (fcntl(sockfd, F_SETOWN, getpid()) == -1) return sock;
>
> val = fcntl(sockfd, F_GETFL, 0) ;
>
> val |= O_NONBLOCK ;
> val |= FASYNC;
> fcntl(sockfd, F_SETFL, val) ;
>
> ------------------------------------------------------------------------------------
>
> Could anyone help me?
>
> Thanks,
>
> Alex
>
>
>
>
> __________________________________________________
> Fale com seus amigos de graça com o novo Yahoo! Messenger
> http://br.messenger.yahoo.com/
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de
Phone: +49-6151-153855 Fax: +49-6151-997714
------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-03-30 11:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-30 2:23 UDP client Alexsandro Soares
2007-03-30 11:28 ` [Caml-list] " Gerd Stolpmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox