C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 06-08-2005, 10:38 PM   #1
Used Registerer
 
jdinger's Avatar
 
Join Date: Feb 2002
Posts: 1,065
Dumb question time - Winsock & accept()

I'm pretty sure I know the answer to this, but I'm VERY new to Winsock.

I'm building the server app and everything works fine until it gets to the accept() call. At that point, it just hangs. There is no client trying to connect. So, I'm guessing the hanging is because of that.

Because I've been through Johnnie's Winsock tutorial and a couple others, and the problem is replicated in all of their code AND mine, I'm thinking it's because it's getting stuck looking for a client, but none is there.

Sorry if this is elementary. I'm an admitted complete Winsock idiot.

Jason
jdinger is offline   Reply With Quote
Old 06-09-2005, 08:51 AM   #2
Registered User
 
Join Date: Nov 2001
Posts: 1,348
There are several solutions on the Win32 platform. One solution is a worker thread. Another solutions is AcceptEx().

Kuphryn
kuphryn is offline   Reply With Quote
Old 06-09-2005, 02:41 PM   #3
Registered User
 
Join Date: Jan 2002
Location: Cardiff
Posts: 2,219
accept() waits until there is a client so it would hang.

Use asynchronous sockets or threads if you want to do something else while it is waiting.
Brian is offline   Reply With Quote
Old 06-09-2005, 03:14 PM   #4
Registered User
 
eth0's Avatar
 
Join Date: Dec 2003
Posts: 164
You could use select() and put the waiting socket in an fd_set
__________________
Open source isn't a matter of life or death......
.......its much more important than that!!


SuSE Linux - GCC 3.4.2
XP Pro - Visual Studio 2005 TS, MinGW 3.4.2
eth0 is offline   Reply With Quote
Old 06-09-2005, 05:11 PM   #5
Used Registerer
 
jdinger's Avatar
 
Join Date: Feb 2002
Posts: 1,065
Thanks, guys.

I'm going to hit up MSDN tonight and study up on the suggestions you've made.

Jason
jdinger is offline   Reply With Quote
Old 06-11-2005, 01:08 AM   #6
#include<xErath.h>
 
xErath's Avatar
 
Join Date: Jun 2004
Posts: 724
you could create a client program to connect to the localhost in a common port.
xErath is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorry for a dumb question. Vanished C++ Programming 7 11-23-2002 12:39 PM
winsock question the Wookie C++ Programming 12 10-17-2002 02:18 AM
dumb question... Sebastiani A Brief History of Cprogramming.com 3 07-28-2002 10:35 AM
time function question heat511 C++ Programming 5 01-03-2002 02:23 PM
time class Unregistered C++ Programming 1 12-11-2001 10:12 PM


All times are GMT -6. The time now is 09:58 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22