CAsyncSocket connect problem #2

Okay,

Here is my network setup:


My pc NIC IP is 10.128.98.121
My remote pc IP is 10.128.98.100


Now I wrote the CAsyncSocket class that will call
Connect("10.128.98.100",
1234).
By right, it should return error trying to establish connection to the
remote pc which is on the same network (as I can PING it) but the
function returns me 0 which means it fails. Why is that?


Am I missing something? 


Mike

0
9/8/2006 2:43:55 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
612 Views

Similar Articles

[PageSpeed] 20

cybernerdsx2 wrote:
> Okay,
> 
> Here is my network setup:
> 
> 
> My pc NIC IP is 10.128.98.121
> My remote pc IP is 10.128.98.100
> 
> 
> Now I wrote the CAsyncSocket class that will call
> Connect("10.128.98.100",
> 1234).
> By right, it should return error trying to establish connection to the
> remote pc which is on the same network (as I can PING it) but the
> function returns me 0 which means it fails. Why is that?
> 
> 
> Am I missing something? 
> 
> 
> Mike
> 

You should GetLastError to find out the reason for the error return. 
Normally, you will get WSAEWOULDBLOCK.  That simply means the operation 
is continuing in the background and your override of OnConnect will be 
called when the real result becomes available.

That's why it's called an 'async' socket.  Instead of blocking your 
program for many seconds it calls you back later.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
9/8/2006 3:26:02 AM
Ok, I overridded the OnConnect() function now but I still get the
errorcode as 0 for ip addresses that I can't ping from my pc
(10.128.98.121).

For example,

myAsync->Connect( "10.1.1.60", 9292 );

This will return 0.


Scott McPhillips [MVP] wrote:
> cybernerdsx2 wrote:
> > Okay,
> >
> > Here is my network setup:
> >
> >
> > My pc NIC IP is 10.128.98.121
> > My remote pc IP is 10.128.98.100
> >
> >
> > Now I wrote the CAsyncSocket class that will call
> > Connect("10.128.98.100",
> > 1234).
> > By right, it should return error trying to establish connection to the
> > remote pc which is on the same network (as I can PING it) but the
> > function returns me 0 which means it fails. Why is that?
> >
> >
> > Am I missing something?
> >
> >
> > Mike
> >
>
> You should GetLastError to find out the reason for the error return.
> Normally, you will get WSAEWOULDBLOCK.  That simply means the operation
> is continuing in the background and your override of OnConnect will be
> called when the real result becomes available.
>
> That's why it's called an 'async' socket.  Instead of blocking your
> program for many seconds it calls you back later.
> 
> -- 
> Scott McPhillips [VC++ MVP]

0
9/8/2006 4:58:16 AM
cybernerdsx2 wrote:
> Ok, I overridded the OnConnect() function now but I still get the
> errorcode as 0 for ip addresses that I can't ping from my pc
> (10.128.98.121).
> 
> For example,
> 
> myAsync->Connect( "10.1.1.60", 9292 );
> 
> This will return 0.

That is normal, as already explained in my previous answer.  Is there 
something about it you don't understand?  When it returns 0 do you call 
GetLastError()?

-- 
Scott McPhillips [VC++ MVP]

0
Scott
9/8/2006 1:24:07 PM
I think he's still thinking that Connect will work immediately.  He's missed the whole
idea of asynchronous sockets, which is that "Connect" means "please start a connection and
get back to me later", and it is *extremely* unlikely that the operation will succeed, and
so 0 is what is expected (and of course, if there were something else wrong, then the
error code would be something other than WSAEWOULDBLOCK, which would mean he has to fix
whatever is wrong).  And somehow he thought that adding OnConnect is going to change the
return code from Connect, which of course it won't.  The connect is, for all practical
purposes, ALWAYS going to fail, every single time, because it is an asynchronous connect.

I'm also curious about the problem relating to an inability to ping.  Since 10.xxx.xxx.xxx
is a private subnet IP address, a ping on the local subnet should work.   If the machine
isn't on the local subnet, then a connect will probably fail, too, but the error code
would not be WSAEWOULDBLOCK.
				joe
On Fri, 08 Sep 2006 09:24:07 -0400, "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
wrote:

>cybernerdsx2 wrote:
>> Ok, I overridded the OnConnect() function now but I still get the
>> errorcode as 0 for ip addresses that I can't ping from my pc
>> (10.128.98.121).
>> 
>> For example,
>> 
>> myAsync->Connect( "10.1.1.60", 9292 );
>> 
>> This will return 0.
>
>That is normal, as already explained in my previous answer.  Is there 
>something about it you don't understand?  When it returns 0 do you call 
>GetLastError()?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/8/2006 3:10:51 PM
Reply:

Similar Artilces:

Having problem of Outlook not receiving new e-mails
I have been using Outlook for over 1 year with Comcast Broadband. Suddenly last week, I received a message that Outlook 2000 was experiencing a problem when receiving new e-mails and was going to shut down. I re-opened Outlook and it looked different and then it asked for me set up a profile and I canceled it. But after that window coming up a couple of times after it shut down, I decided to put in a new name and then I could not get to my old e-mails and it acted like a new set up. Then I really got frustrated. I was eventaully able to get back to my old e-mails and have been able t...

parsing a date and time field #2
I am having trouble parsing the date and time in a field. I download data from a data base and the date and time come together in one field. I want to seperate the two. The date and time comes across as the following: "2/1/2009 14:37" in the cell. When I parse it, it seperates into three columns as follows: "2/1/2009", 2:37 AM", and "PM" I can see what is going on but I would like to get two columns with one as the date and the other as the correct time. are they any ideas on how to address this? Try using the TimeValue and DateValue functions. First format ...

connecting livemail
using internet explorer 8. Clicking desktop icon gives me my hotmail folders but it won't connect so can't send or receive emails. But if I go to hotmail website,I can access fully functioning hotmail -but with different (not so convenient) format. What can I do to restore connection to usual email? Problem arose 29 july -before that access and connection were ok. Please keep it simple! -- In earnest ...

Filter driver installation problem! 01-06-10
Hi, I developed a disk low filter driver and want to load this driver at Windows setup procedure, I don't know how to do that? It seems only using INF file does not work? Any suggestion? thanks. Best Regards, Perer, By Windows setup, do you mean install of Windows? If so look at http://www.osronline.com/article.cfm?id=264 this covers the subject for XP and 2003. For later OS'es get the WAIK http://www.microsoft.com/downloads/details.aspx?FamilyID=C7D4BC6D-15F3-4284-9123-679830D629F2 and start digging. -- Don Burn (MVP, Windows DKD) Windows F...

Controlling multiple TCP connections from Outlook 2003 clients
I've noticed that Outlook 2003 clients can have multiple TCP connections to the mailbox store on Exchange. As the following web link claims: http://www.windowsitpro.com/Article/ArticleID/46319/46319.html "This behavior is by design. Outlook can open multiple connections to parallelize its data communications with the Exchange server. The actual number of connections will vary according to the version of Outlook that you're using and the mode in which you're using it. For Microsoft Office Outlook 2003 in Cached Exchange Mode, you'll see four connections for the mailbox, ...

Money Central Portfolio #2
My print function has gotten corupted. When I print it flips to WORD / format and prints in a format that is 4x normal. ...

macro #2
I am pretty new to using (or attempting to use) a Macro in a workbook. I am having trouble following how and what to do to even start the process; ie If there needs to be a worksheet already in progress or can I start from a new sheet. THEN where to go from there. Can I have some help in this area? Can some one supply me with a sample MACRO? Any help would be greatly appreciated Dan The best way to get started with macros is to use the Macro Recorder. Go to the Tools menu, choose Macros, then Record New Macro. Then, carry out some simple tasks and examine the code that is produced. ...

merging 2 cells without losing data?
How can I merge 2 cells without losing data from the other cell? Hi Bob Not possible I'm afraid. Try placing the dat from both cells into one and use "Center across selection" under Format>Cells>Alignment Merge cells always end up causing grief. they are best avoided. ***** Posted via: http://www.ozgrid.com Excel Templates, Training & Add-ins. Free Excel Forum http://www.ozgrid.com/forum ***** "bob" <bobree@hotmail.com> wrote in message news:%23JuOM9HGEHA.2308@tk2msftngp13.phx.gbl... > How can I merge 2 cells without losing data from the other...

Statements #2
How are statements sorted? Alphabetically by name or by account number? Does anybody know? -- Any help is appriciated, Deb Mine are done alphabetically by name. -- Elizabeth M. "Deb" <Deb@discussions.microsoft.com> wrote in message news:D58FEF32-7509-473B-A554-6A48E02697CF@microsoft.com... > How are statements sorted? Alphabetically by name or by account number? > Does > anybody know? > -- > Any help is appriciated, Deb ...

how to config Server for one user which has 2 mail address.
we have one NT4.0 + Exchange 5.5 Server "A" Email abc@xxx.com.cn ��and another windows2003 + exchange 2003 Server "B" abc@cn.xxx.com user name is same in A B��Mx record was be set ,question is how to config Exchange 2003 to receive down the mail to Server A , because of we need to replace A with B. thanks a lot. E2K3 setup guides you through common scenarios (like yours) pretty much holding your hand - on welcome screen tell it that you have existing E55 org and want to join it, then follow on-screen instructions. Having usable backup of Exchange databases and AD i...

Dropped connection to POP3 servers
Just installed Office 2003 under XP Home. Outlook is dropping connection to POP3 servers, I check 2 different servers with a S/R. Both fail at the same time, never separately. Sometimes I can exit Outlook gracefully but a reboot is required to get Outlook to work again. Sometimes locks entire system and have to powerdown manually. Pattern not fully determined but it appears to happen when there is other activity to the internet that is going to specific servers using an ID and password. I use Medved Quotetracker with E*Trade quotes (requires ID). If I bring up Quotetracker, Ou...

An Outlook 2003 Problem
I just upgraded from Outlook 97 to Outlook 2003. However, when trying to reply, forward, and compose with Outlook 2003, I got this error message: "The messaging interface has returned an unknown error. If the problem persists, restart Outlook." The problem persisted. I restarted Outlook 2003, but it didn't help. Any suggestions? Thanks. How did you upgrade Outlook 2003 from Outlook 97? Anyway If you use Hotmail or MSN mail, check MSKB info below. You receive a "The messaging interface has returned an unknown error " error message when you try to use Outlook to...

Exchange Server 2000 Secuirty Setup problems
Dear I have apply wrong setting to our exchange server 2000 . The wrong setting as from exchange manager . mail store , I have apply everyone send as and receive as access right, the group included remote access via offline sync. This setting once apply , all user access other mailbox without apply access right. I have try disable this setting, after all local office user no problems, but a remote offline sync laptop user does not work . The error as below: Unable to display the folder. Microsoft Outlook could not access the specified folder location. The file C:\exchange\shawnb.ost cannot b...

Problems Converting Data from Quicken 2001 Deluxe to MS Money
Hello, I have a relatively new Compaq Desktop (2.5 GHz Celeron with 512 MB RAM). I have a Viewsonic Pocket PC and I wanted to use it to track my financial data so I purchased Money 2003 Standard. I tried several times to convert my Qucken Data (it's a big file--I've been using Quicken since 1995). My Quicken program is Quicken 2001 Deluxe. Anyway, the MS Money program started to convert and after a few minutes said: "Your Quicken file could not be converted. Money could not convert your Quicken file. You might have run out of disk space or system memory. Try closing othe...

CRM 4.0 Custom Report Filter Problem
I am using the Report Wizard to create a simple report. Report is using Quotes and Quote Products I have a custom field in Quote Products which is a bit field Yes-No When I use that field as a filter for report output, I get all records. The filter criteria appears to be ignored Is this an inherent problem with Report Wizard or Am I doing something wrong? Thanks. depends on your business logic and what you want to see. If you have three quotes: Quote-1 has three products, all with the custom field set to Yes Q2 has three products, two set to Yes, 1 to No Q3 has three products, all set...

Macro
Here is one for you experts - I am a novice I want to add a macro to a worksheet that will print selected information held on certain rows of the worksheet. Once the 'button' has been selected a mesage box will pop up asking the user to input which row number he/she wishes to print. On input that number is matched to the corresponding row of the worksheet and that row is copied (without any formula - just cell values) and pasted into another worksheet where it is placed into other formats and printed. Seems like a simple(!!) job - but far to difficult for me to programme Can an...

Help! Problem Referencing Excel 2003 in VB.NET
I am using Visual Studio 2008 Express Edition to develop some VB.NET code that manipulates Excel files. I am developing on a Vista/Excel 2007 machine, but I need the code to work on an XP/2003 machine as well. I initially set a reference to the Microsoft Excel 12.0 Object Library and imported the Microsoft.Office.Interop.Excel namespace. This works great on the VIsta/Excel 2007 machine, but it does not work on 2003, which needs the 11.0 library. I get an error that says "Unhandled Exception . . . Could not file or assembly 'Microsoft.Office.Interop.Excel, Version 12.0.0....

Duplicate personal folders problem
Hello all, I have a problem with Outlook 2003 and I hope someone can help me resolve it I imported a PST file from Outlook XP that was on a different machine, and now I have two versions of Personal Folders in my All Mail Folders list. They both have Deleted Items, Drafts, Inbox, Junk E-mail, Outbox, Sent Items and Search Folders in. One of them has an icon of a piece of paper with a clock to the top left and a house to the top right. The other one has an icon like a stack of files (like from a filing cabinet) They are clearly referencing the same thing, as the Deleted Items both have al...

Sum amount if = 2 value's
I have a spreadsheet of payment types for which I want to sum the tota amount per type per month A B C Type Amount Month I'm able to get the total amount per type by usin =SUMIF(A:A,"TYPE",B:B), but can't work out how to get a total for eac type each month Somthing along these lines: =SUMIF((A:A,"TYPE",B:B)&C:C,"MONTH")) ???? Any idea's -- loscherlan ----------------------------------------------------------------------- loscherland's Profile: http://www.excelforum.com/member.ph...

Excel Problem #3
I have win2000 with Office 2000 in the network! When i try to rename one excel file my computer make restart. This hapening not to all files,and all files there are in the same folder in the network! What hapen,and what i can do so as to work out the problem? I have all the required permissions on that network folder. No one else has any of the files open. They are not shared workbooks. ...

Excel pivot table #2
i encountered an error in my pivot table. i created an olap cube using the analysis manager. the cube displays the correct data of my measures but on my pivot report, it displays #N/A.... i need help to fix this one... thanks.... =) ...

Interesting Solver problem (Solver encounters an error)
Here's an interesting problem, I wonder if anyone has any thoughts o this. Recognize that my real problem is very complex (severa intermediate calculation including some iterative steps), but th problem I'm having seems similar (conceptually anyway) to this simpl problem. Given a data set: x,y 10,3.9 8,3.2 7,2.8 6,2.2 5,1.4 4.5,0.8 4,0.01 3.8,-0.4 3.6,-1 3.5,-1.4 3.4,-1.8 3.3,-2.4 3.2,-3.2 3.1,-4.6 3.05,-6 One could look at the data and say, "that looks like the curve y=ln(x) but with a different asymptote other than the y-axis and possibly scaling factor." So we choos...

Problems with MFC list controls
I have a large list control with many inventory control items displayed within. When someone single clicks on an item, it displays information about that item in another part of the dialog. I have a three-fold problem, the master list has multiple columns in it, in order to make the selection work properly, only column 0 can be selected, is there a way to make a valid row selection if you select an item using any of the other columns? Second issue is the highlight of the selection. Only column 0 in the list control will highlight, is there a way to make the entire row highlight when an...

Next button problems
I have a next button in a form that I have criteria for. I have a date field that has to be entered before going to another record. When I click the next button I get the pop up that says click update to continue but the form displays the next record instead of staying on the current record that needs updating. Here is the code that I am using. ____________________________________________________________________________________ Private Sub Command39_Click() If IsNull([Post Called Customer]) Then MsgBox "You must click the UPDATE button to continue!!!" Cancel = True End If On Erro...

Outlook Express 6 Spell Check #2
I am using Outlook Express 6 on Windows XP, and I have a problem with spell check. When you send an email, it says "spell check has been haulted, do you want to send anyway" and if I ask it to spell check, it says an error has occured in spell check. All my spelling options are correctly set, so I don't know what the problem is. Kimberly McNabb <knmcnabb@hotmail.com> wrote: > I am using Outlook Express 6 on Windows XP, and I have a > problem with spell check. Ask in an Outlook Express newsgroup. -- Brian Tillman ...