sockets

hi everyone.i need a small help in C.
i want to know if there can be a socket which is a blocking one.just the syntax and header files necessary.something like the socket has to wait untill it gets a packet

Replies

  • elric
    elric
    i guess you are asking the syntax to functions to make a basic server, to do this you need to use listen() first and then accept()
    their prototypes are
    #include
    int listen(int sockfd, int backlog);
    int accept(int sockfd, void *addr, int *addrlen);

    the sequence of system calls you will do is
    socket();
    bind();
    listen();
    accept();

    i hope you do know how to use socket() and bind() if not google it up or refer a good networking programming book cause you will have to take care of specifing addresses in host-byte order or network-byte order. There is a good guide to network programming on the net too, Beej's Guide to Network Programming , is short and concise. check it out. Also the above details is for gcc.
  • dropcards
    dropcards
    usually the socket is blocking unless you set it otherwise with ioctl

You are reading an archived discussion.

Related Posts

please explain me the difference between a comparator and an opamp based on the examples given below... 1) if my v+ is 12v and my v- is 0v, input +...
can you please tell me some new seminar topics on information technology
Where can 1 get the code of C compiler?
Dear all, Good morning to everybody. I am very ahppy to join this fourm.I am a electrilal engineer working as a project Manager for a leading engineering firm.My nature of...
Hello! I want to know more about electronic engineering, so my computer show me this site. Suddenly i realise that really electronics is one of the best branch and when...