int main(int argc, char **argv) { int sctpInstance; SCTP_ulpCallbacks terminalUlp; SCTP_InstanceParameters instanceParameters; sctp_initLibrary(); /* trapping Ctrl-C */ signal(SIGINT, finish); /* trapping Ctrl-backslash */ signal (SIGQUIT, finish); /* initialize the terminal_ulp variable */ terminalUlp.dataArriveNotif = &dataArriveNotif; terminalUlp.sendFailureNotif = &sendFailureNotif; terminalUlp.networkStatusChangeNotif = &networkStatusChangeNotif; terminalUlp.communicationUpNotif = &communicationUpNotif; terminalUlp.communicationLostNotif = &communicationLostNotif; terminalUlp.communicationErrorNotif = &communicationErrorNotif; terminalUlp.restartNotif = &restartNotif; terminalUlp.shutdownCompleteNotif = &shutdownCompleteNotif; terminalUlp.peerShutdownReceivedNotif = NULL; /* handle all command line options */ getArgs(argc, argv); checkArgs(); if (client) { sctpInstance = sctp_registerInstance(localPort, MAXIMUM_NUMBER_OF_IN_STREAMS, MAXIMUM_NUMBER_OF_OUT_STREAMS, noOfLocalAddresses, localAddressList, terminalUlp); /* set the TOS byte */ sctp_getAssocDefaults(sctpInstance, &instanceParameters); instanceParameters.ipTos=tosByte; sctp_setAssocDefaults(sctpInstance, &instanceParameters); associationID = sctp_associate(sctpInstance, MAXIMUM_NUMBER_OF_OUT_STREAMS, destinationAddress, remotePort, NULL); } sctp_registerUserCallback(fileno(stdin),&stdinCallback, NULL, POLLIN|POLLPRI); /* run the event handler forever */ while (sctp_eventLoop() >= 0); /* this will never be reached */ return 0; }
int SCTP_registerUserCallback(int fd, sctp_userCallback sdf, void* userData) { int result; if ((result = sctp_registerUserCallback(fd, sdf, userData, POLLIN|POLLPRI)) < 0) { fprintf(stderr, "sctp_registerUserCallback: error value (%i) returned.\n", result); fflush(stderr); } return result; }