CrazyEngineers Forum

******************************************
Welcome To CrazyEngineers (CE) – an online community of engineers from all over the world! With the younger CEan at 84 and the youngest at 16, CE boasts of professional engineers, students, professors, entrepreneurs, CEOs, geeks & nerds. We exchange innovative ideas, share knowledge, help each other and expand our worldwide network of engineers! You need not have a formal degree in engineering to be a part of CrazyEngineers! Need we say more?
Join CE! | Be a CE Ambassador! | Forgot password? | Sponsor CE | Contact Us
Navigation
Reply

  #1 (permalink)
Old 9th June 2008, 09:12 PM
CE - Apprentice
 
I'm a Crazy computer science Engineer
Join Date: 25th September 2006
Location: chennai
Posts: 36
Default 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

Last edited by sahana : 9th June 2008 at 09:27 PM.
sahana is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored links
  #2 (permalink)
Old 16th June 2008, 01:02 AM
CE - Apprentice
 
I'm a Crazy Electrical, Electronics Engineer
Join Date: 14th June 2008
Posts: 22
Default Re: sockets

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 <sys/socket.h>
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.
__________________
With complexity comes consciousness
elric is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)
Old 17th June 2008, 05:10 AM
CE - Newbie
 
I'm a Crazy realisticdropcard Engineer
Join Date: 17th June 2008
Posts: 1
Default Re: sockets

usually the socket is blocking unless you set it otherwise with ioctl
dropcards is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored links
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 10:07 PM.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Member comments are owned by the poster. Copyright © 2005-2008 CrazyEngineers.com. All rights reserved.Ad Management by RedTyger