int val; val = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) == -1) { perror("Setsocketopt failed "); exit(-1); }
where.sin_addr.s_addr = INADDR_ANY; where.sin_port = htons(5600); where.sin_family = AF_INET; if (bind(s,(struct sockaddr *) &where, sizeof(where)) == -1) { perror("Bind of socket failed"); exit(-1); }
if (listen(s, 5) == -1) { perror("Listen Failed "); exit(-1); }
sotlen = sizeof(sot); while (( ns = accept(s,&sot, &sotlen)) != -1) { }