Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/runtime/c-libs/smlnj-sockets/accept.c
ViewVC logotype

Annotation of /sml/trunk/src/runtime/c-libs/smlnj-sockets/accept.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 727 - (view) (download) (as text)

1 : monnier 249 /* accept.c
2 :     *
3 :     * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
4 :     */
5 :    
6 :     #include "ml-unixdep.h"
7 :     #include "sockets-osdep.h"
8 :     #include INCLUDE_TYPES_H
9 :     #include INCLUDE_SOCKET_H
10 :     #include "ml-base.h"
11 :     #include "ml-values.h"
12 :     #include "ml-objects.h"
13 :     #include "ml-c.h"
14 :     #include "cfun-proto-list.h"
15 :    
16 :     /* _ml_Sock_accept : sock -> (sock * addr)
17 :     */
18 :     ml_val_t _ml_Sock_accept (ml_state_t *msp, ml_val_t arg)
19 :     {
20 :     int sock = INT_MLtoC(arg);
21 :     char addrBuf[MAX_SOCK_ADDR_SZB];
22 :     int addrLen = MAX_SOCK_ADDR_SZB;
23 :     int newSock;
24 :    
25 :     newSock = accept (sock, (struct sockaddr *)addrBuf, &addrLen);
26 :    
27 :     if (newSock == -1)
28 :     return RAISE_SYSERR(msp, newSock);
29 :     else {
30 : jhr 727 ml_val_t data = ML_CData (msp, addrBuf, addrLen);
31 :     ml_val_t addr, res;
32 : monnier 249
33 : jhr 727 SEQHDR_ALLOC(msp, addr, DESC_word8vec, data, addrLen);
34 : monnier 249 REC_ALLOC2(msp, res, INT_CtoML(newSock), addr);
35 :     return res;
36 :     }
37 :    
38 :     } /* end of _ml_Sock_accept */

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0