Click here to Skip to main content
12,250,675 members (44,458 online)

ATL / WTL / STL

 
JokeRe: get instance of object (in exe) from dll caller Pin
pasztorpisti17-Sep-12 13:43
memberpasztorpisti17-Sep-12 13:43 
GeneralRe: get instance of object (in exe) from dll caller Pin
pasztorpisti17-Sep-12 13:48
memberpasztorpisti17-Sep-12 13:48 
AnswerRe: get instance of object (in exe) from dll caller Pin
Richard MacCutchan17-Sep-12 22:16
mvpRichard MacCutchan17-Sep-12 22:16 
AnswerRe: get instance of object (in exe) from dll caller Pin
Stephen Hewitt18-Sep-12 18:49
memberStephen Hewitt18-Sep-12 18:49 
QuestionCAsyncSocket Connect says in use Pin
bkelly1316-Sep-12 6:07
memberbkelly1316-Sep-12 6:07 
Answerunexpected behavior Pin
bkelly1316-Sep-12 10:07
memberbkelly1316-Sep-12 10:07 
AnswerRe: CAsyncSocket Connect says in use Pin
Richard Andrew x6416-Sep-12 11:53
memberRichard Andrew x6416-Sep-12 11:53 
AnswerRe: CAsyncSocket Connect says in use Pin
pasztorpisti16-Sep-12 12:05
memberpasztorpisti16-Sep-12 12:05 
Well, I've done some TCP socket programming in the past but haven't used the CAsyncSocket class. What is interesting for me is that listen() returns EWOULDBLOCK for you. listen() should never return EWOULDBLOCK if you take a look at its documentation. listen() is always blocking but only for a very short time, it either returns failure or does its job (establises incoming connection request queue, the backlog) and returns with success.
So whats wrong with your code? Here is my guess: After starting the listen you unnecessarily issue some other request on your listen socket (for example an accept() call) and that results in a WSAEWOULDBLOCK message that is not still not the end of the world, but strange and you should check out the reason for this. About the WSAEADDRINUSE problem: If your listening starts as expected then it allocates and uses a port on your machine. When you connect the client side should issue a connect() call that results in the following events: your server side receives an event and as a result calls accept(). Both the server side accept() call and the client side connect() call returns a socket that has random ports assigned. HOWEVER: If your misterious CAsyncSocket class calls bind() before the connect() call, then it will fix the port of the returned socket by the connect() call and if that is the same as the port on which your server is listening then the socket can not be created on the client side! You should make sure that bind isn't called before connect() allowing the connect() call to assign a random port for the client side socket! bind() is usually used before connect when your firewall allows only specific ports for the software to communicate.
Another side note: WSAEADDRINUSE might return if you shut down your program during debugging. In this case some of your sockets might stay alive inside the network subsystem because of lingering. In this case sometimes you have to wait for minutes for that socket object to diminish from the network subsystem so as to release your ports.
GeneralRe: CAsyncSocket Connect says in use Pin
bkelly1316-Sep-12 12:55
memberbkelly1316-Sep-12 12:55 
GeneralRe: CAsyncSocket Connect says in use Pin
pasztorpisti16-Sep-12 13:09
memberpasztorpisti16-Sep-12 13:09 
GeneralRe: CAsyncSocket Connect says in use Pin
bkelly1316-Sep-12 13:17
memberbkelly1316-Sep-12 13:17 
GeneralRe: CAsyncSocket Connect says in use Pin
pasztorpisti16-Sep-12 13:34
memberpasztorpisti16-Sep-12 13:34 
GeneralRe: CAsyncSocket Connect says in use Pin
bkelly1316-Sep-12 14:07
memberbkelly1316-Sep-12 14:07 
Questionbetter version of strcpy() and printf() Pin
bkelly1315-Sep-12 10:02
memberbkelly1315-Sep-12 10:02 
AnswerRe: better version of strcpy() and printf() Pin
Paul Watt15-Sep-12 12:33
mentorPaul Watt15-Sep-12 12:33 
GeneralRe: better version of strcpy() and printf() Pin
bkelly1315-Sep-12 15:34
memberbkelly1315-Sep-12 15:34 
GeneralRe: better version of strcpy() and printf() Pin
Paul Watt15-Sep-12 15:45
mentorPaul Watt15-Sep-12 15:45 
GeneralRe: better version of strcpy() and printf() Pin
bkelly1315-Sep-12 16:23
memberbkelly1315-Sep-12 16:23 
GeneralRe: better version of strcpy() and printf() Pin
pasztorpisti16-Sep-12 6:54
memberpasztorpisti16-Sep-12 6:54 
GeneralRe: better version of strcpy() and printf() Pin
Richard MacCutchan16-Sep-12 0:10
mvpRichard MacCutchan16-Sep-12 0:10 
AnswerRe: better version of strcpy() and printf() Pin
Richard Andrew x6415-Sep-12 17:01
memberRichard Andrew x6415-Sep-12 17:01 
AnswerRe: better version of strcpy() and printf() Pin
Richard MacCutchan16-Sep-12 0:09
mvpRichard MacCutchan16-Sep-12 0:09 
AnswerRe: better version of strcpy() and printf() Pin
pasztorpisti16-Sep-12 1:37
memberpasztorpisti16-Sep-12 1:37 
AnswerRe: better version of strcpy() and printf() Pin
Stephen Hewitt18-Sep-12 0:29
memberStephen Hewitt18-Sep-12 0:29 
Questionget a number into static text control Pin
bkelly1313-Sep-12 17:05
memberbkelly1313-Sep-12 17:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.160426.1 | Last Updated 2 Mar 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid