Log In
New Account
  
 
Home My Page Project Tree Code Snippets Project Openings NUTSS
 
 
Summary Tracker Lists CVS Files
 

CVS | Administration

Annotation of libnutss/examples/asynchtest.c, revision 1.1

1.1     ! saikat      1:
        !             2: #include <stdio.h>
        !             3: #include <stdlib.h>
        !             4: #include "nutss.h"
        !             5:
        !             6: #ifdef WIN32
        !             7: #define snprintf _snprintf
        !             8: #endif
        !             9:
        !            10: #define EXCH 100000
        !            11: //#define TEST_ONE_PROCESS
        !            12:
        !            13: //int _tmain(int argc, _TCHAR* argv[])
        !            14: int main(int arg, char ** argv)
        !            15: {
        !            16:       char* proxy =  "sip.nutss.net:5060";
        !            17:       char * user =  "ari1";
        !            18:       char *domain = "nutss.net";
        !            19:
        !            20:       char * pw = "password";
        !            21:       char* listeningUser = user;  //person to connect to
        !            22:       char * svcuname = "admin";
        !            23:       char * svcdomain = "nutss.net";
        !            24:       struct sockaddr_ns nct;
        !            25:       int zero = 0;
        !            26:     int one = 1;
        !            27:       struct fd_set readfds;
        !            28:       SOCKET s;
        !            29:
        !            30:       printf("test starting\n");
        !            31:
        !            32:       putenv("NUTSS_CERT=client.pem:password@root.pem");
        !            33:
        !            34:       nutss_config_set(NUTSS_CONFIG_USERNAME, user, strlen(user));
        !            35:       nutss_config_set(NUTSS_CONFIG_PROXYUSERNAME, user, strlen(user));
        !            36:       nutss_config_set(NUTSS_CONFIG_PROXYPASSWORD, pw, strlen(pw));
        !            37:       nutss_config_set(NUTSS_CONFIG_DOMAINNAME, domain, strlen(domain));
        !            38:       nutss_config_set(NUTSS_CONFIG_SIGPROXY, proxy, strlen(proxy));
        !            39:       nutss_config_set(NUTSS_CONFIG_OPT_SECURE, &zero, sizeof(zero));
        !            40:       nutss_config_set(NUTSS_CONFIG_SVCUSERNAME, svcuname, strlen(svcuname));
        !            41:       nutss_config_set(NUTSS_CONFIG_SVCDOMAINNAME, svcdomain, strlen(svcdomain));
        !            42:       nutss_init();
        !            43:
        !            44:       memset(&nct,0, sizeof(nct));
        !            45:      //now set up nct for the connect
        !            46:       nct.family = AF_NUTSS;
        !            47:
        !            48:       strncpy(nct.user, listeningUser, sizeof(nct.user));
        !            49:       strncpy(nct.domain, domain, sizeof(nct.domain));
        !            50:       strncpy(nct.service, "nutsstestapp", sizeof(nct.service));
        !            51:
        !            52:       s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        !            53:   0 != nutss_bind(s, (struct sockaddr *)&nct, sizeof(nct)))
        !            54:       {
        !            55:      printf("failed to bind correctly\n");
        !            56:      exit(0);
        !            57:       }
        !            58:       else
        !            59:      listen(s, 10);
        !            60:
        !            61:       ioctlsocket(s, FIONBIO, (unsigned long *) &one);
        !            62:       printf("socket set to nonblocking\n");
        !            63:
        !            64:       FD_ZERO(&readfds);
        !            65:       FD_SET(s, &readfds);
        !            66:       if(! select(1, &readfds, 0,0,0))
        !            67:      printf("select returned no fds\n");
        !            68:       else
        !            69:       {
        !            70:      SOCKET s2;
        !            71:      printf("\nselect succeeded\n\n");
        !            72:      s2= nutss_accept(s, 0, 0);
        !            73:      if(s2 != INVALID_SOCKET)
        !            74:     printf("\n\n----\nsocket successfully opened\n--\n\n");
        !            75:      else
        !            76:      {
        !            77:     printf("open failed: %d\n", errno);
        !            78:     exit(0);
        !            79:      }
        !            80:      //
        !            81:       }
        !            82:
        !            83:       Sleep(1000000);
        !            84:
        !            85:       return 0;
        !            86: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
 

GForge.cis.cornell.edu is brought to you by

Cornell Computing and Information Science


Powered By GForge Collaborative Development Environment