Search Results

Search found 2 results on 1 pages for 'rileyvanzeeland'.

Page 1/1 | 1 

  • c unix- Select() send and receive with same socket descriptor

    - by RileyVanZeeland
    I am wanting to use select to receive and send on a client/server on the same socket descriptor (serverside). timestruct* myTime; sockfd = accept(listeningFd, 0, 0); while(1) FD_ZERO(&my_fd_set) maxFd = sockfd FD_ZERO(&my_fd_set); FD_SET(sockfd, &my_fd_set); select(maxFd+1, &my_fd_set, &my_fd_set, NULL, myTime); for (j=0; j<=maxFd; j++) if(FD_ISSET(j, &temp_fd_set)) if(j==sockfd) send() if(j==sockfd) recv() This is essentially what I want to do. Obviously this won't work because sockfd is going to be the same value for sending and receiving. Is there a way I can do this without using fork()?? Currently I have a blocking recv and send but the server could be required to recv multiple commands while another command is being processed to send back to the client. I am very knew to c and also 'select()'. Because select has the three fd_set options (read, write, execute) I thought maybe I could do this. Thank you.

    Read the article

  • cygwin c sem_init

    - by RileyVanZeeland
    if((sem_init(sem, 1, 1)) == 1) perror("error initiating sem"); If I include this line of code my program simply starts and exits. I just started learning how to use semaphores. I'm using cygwin and when this line is commented out the printf's ABOVE this print to console but when include this, nothing happens. I did the following to get cygserver going- CYGWIN=server ran /bin/cygserver-config ran /usr/sbin/cygserver for the config it said the cygserver is already running And for the sygserver it saids- initailaizing complete failed to created named pipe: is the daemon already running? fatal error on IPC transport: closing down Any ideas?

    Read the article

1