1 /*
2
3 Written by Barry Smith, bsmith@mcs.anl.gov 4/14/92
4 Updated by Richard Katz, katz@ldeo.columbia.edu 9/28/03
5 */
6
7 #include <petscsys.h>
8 #include <../src/sys/classes/viewer/impls/socket/socket.h>
9
10 #include <errno.h>
11 #include <ctype.h>
12 #if defined(PETSC_HAVE_MACHINE_ENDIAN_H)
13 #include <machine/endian.h>
14 #endif
15 #if defined(PETSC_HAVE_UNISTD_H)
16 #include <unistd.h>
17 #endif
18 #if defined(PETSC_HAVE_SYS_SOCKET_H)
19 #include <sys/socket.h>
20 #endif
21 #if defined(PETSC_HAVE_SYS_WAIT_H)
22 #include <sys/wait.h>
23 #endif
24 #if defined(PETSC_HAVE_NETINET_IN_H)
25 #include <netinet/in.h>
26 #endif
27 #if defined(PETSC_HAVE_NETDB_H)
28 #include <netdb.h>
29 #endif
30 #if defined(PETSC_HAVE_FCNTL_H)
31 #include <fcntl.h>
32 #endif
33 #if defined(PETSC_HAVE_IO_H)
34 #include <io.h>
35 #endif
36
37 #if defined(PETSC_NEED_CLOSE_PROTO)
38 PETSC_EXTERN int close(int);
39 #endif
40
41 #include <mex.h>
42 #define PETSC_MEX_ERROR(a) \
43 { \
44 mexErrMsgTxt(a); \
45 return; \
46 }
47 typedef struct {
48 int onoff;
49 int time;
50 } Linger;
51
mexFunction(int nlhs,mxArray * plhs[],int nrhs,const mxArray * prhs[])52 PETSC_EXTERN void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
53 {
54 int t = 0;
55 Linger linger;
56
57 linger.onoff = 1;
58 linger.time = 0;
59
60 if (!nrhs) PETSC_MEX_ERROR("Needs one argument, the port");
61 t = (int)*mxGetPr(prhs[0]);
62
63 if (setsockopt(t, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof(Linger))) PETSC_MEX_ERROR("Setting linger");
64 if (close(t)) PETSC_MEX_ERROR("closing socket");
65 return;
66 }
67
main(int argc,char ** argv)68 int main(int argc, char **argv)
69 {
70 return 0;
71 }
72