/* Written by Barry Smith, bsmith@mcs.anl.gov 4/14/92 Updated by Richard Katz, katz@ldeo.columbia.edu 9/28/03 */ #include #include <../src/sys/classes/viewer/impls/socket/socket.h> #include #include #if defined(PETSC_HAVE_MACHINE_ENDIAN_H) #include #endif #if defined(PETSC_HAVE_UNISTD_H) #include #endif #if defined(PETSC_HAVE_SYS_SOCKET_H) #include #endif #if defined(PETSC_HAVE_SYS_WAIT_H) #include #endif #if defined(PETSC_HAVE_NETINET_IN_H) #include #endif #if defined(PETSC_HAVE_NETDB_H) #include #endif #if defined(PETSC_HAVE_FCNTL_H) #include #endif #if defined(PETSC_HAVE_IO_H) #include #endif #if defined(PETSC_NEED_CLOSE_PROTO) PETSC_EXTERN int close(int); #endif #include #define PETSC_MEX_ERROR(a) \ { \ mexErrMsgTxt(a); \ return; \ } typedef struct { int onoff; int time; } Linger; /*-----------------------------------------------------------------*/ /* */ /*-----------------------------------------------------------------*/ PETSC_EXTERN void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int t = 0; Linger linger; linger.onoff = 1; linger.time = 0; if (!nrhs) PETSC_MEX_ERROR("Needs one argument, the port"); t = (int)*mxGetPr(prhs[0]); if (setsockopt(t, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof(Linger))) PETSC_MEX_ERROR("Setting linger"); if (close(t)) PETSC_MEX_ERROR("closing socket"); return; } int main(int argc, char **argv) { return 0; }