Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Wrox Announcements and Feedback > All Other Wrox Books
| Search | Today's Posts | Mark Forums Read
All Other Wrox Books Do you have a question about a Wrox book that isn't listed anywhere on p2p.wrox.com or where the forum is locked? Here's a forum to post questions about any other Wrox book so that other readers or one of the authors can help you with your questions. IF YOU ARE LOOKING FOR CODE DO NOT ASK "Where can I find the code for this book?" That question is answered here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the All Other Wrox Books section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 20th, 2004, 12:35 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Professional .NET Network Programming

[I'm new, this is my first post, in case you dont recognize my username]

Hi everyone,

    hopefully someone can answer this for me, I've tried investigating this a little bit but cant find anything concrete. Pages 146-156 of .NET Network programming show a asynchronous programming example, where some text is excahnged between a client and a server. I downloaded the code and compiled the files, and ran both asyncserver and asyncclient, to see the code in action. Only thing I get an exception everytime I run the client (assume the server is running). The server does get the text from the client, but when the server bounces the text back to the client, I get an exception w/ the client's EndReceive method. The key part of the message is that "connection was forcibly closed by the remote host." In the server code, after the send, it uses a Shutdown( SocketShutdown.Both ) followed by a Close() call. That seems ok. What appears to be happening is that when the client wants to receive the data, the server has already closed the connection, so an exception occurs, at least according to my understanding. I could be mistaken. I've tried "hacks" such as putting a thread here or there to sleep, but nothing seems to work. I even set the linger option of the server's socket to 5, so it hangs around presumably when close is called. But I still get the exception. Does that mean that the data transfers so fast that no data is seen in the network queue when close() is called (so the fact I set a linger option doesnt matter at that point), but the client cant use the connection b/c of the close() call. The only thing I've been able to do to get it to function is to change the socketoption to SocketShutdown.Recieve instead, and that makes it work.
    Sorry for the long post, but I wanted to be thorough. Was the only way of getting it to work by changing the shutdown option? I mean, I guess I was expecting the code to work, but I know that isnt the case all the time. Has anyone else had the same problem on their computers? I guess that's all for now. Thanks for anyone that answers.

Bryan.

  #2 (permalink)  
Old September 22nd, 2004, 08:35 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure if your still looking. I too had the problem with the example given. Not sure what the problem is. They don't go into too many details in the book on how the classes are designed. I do have a working Client server control that can stream binary objects back and forth in parallel you could look at. I think the code is alot easier to understand.

Email me: gavin@abis.biz if your still interested.

Gavin Stevens
MCSD.NET, MCAD.NET, MCSD, MCP
gavin@abis.biz

  #3 (permalink)  
Old December 20th, 2004, 06:23 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nugie73 Send a message via Yahoo to nugie73
Default

Just change the following line at Server Application:

if (content.IndexOf(".") > -1)

into

if (content.IndexOf("<TheEnd>") > -1)

at method "public static void ReceiveCallback(IAsyncResult ar)"

hope it helps.:)







Similar Threads
Thread Thread Starter Forum Replies Last Post
Pro .NET Network Programming jeff5509 All Other Wrox Books 7 August 2nd, 2010 09:03 AM
code of 'professional .net network programming' shixiaoming General .NET 2 April 13th, 2010 01:08 AM
Professional .NET Network Programming in french ? neozzz Wrox Book Feedback 2 February 23rd, 2004 02:46 PM
.NET Network Programming Error TripleClamps All Other Wrox Books 0 August 13th, 2003 07:20 PM
.NET Network Programming Error TripleClamps .NET Web Services 0 August 13th, 2003 06:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.