A different Winsock problem
A different Winsock problem
A different Winsock problem
A different Winsock problem
A different Winsock problem
A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem
A different Winsock problem A different Winsock problem
A different Winsock problem
Go Back  Xtreme Visual Basic Talk > > > A different Winsock problem


Reply
 
Thread Tools Display Modes
  #1  
Old 11-04-2010, 02:54 PM
wayneh wayneh is offline
Centurion
 
Join Date: Mar 2004
Posts: 123
Question A different Winsock problem


OK -

I'm using UDP to connect peer-to-peer with Winsock.

However, if one of the Peers shuts down unexpectedly, the other Peer
never knows.

Winsock never throws an error when I issue the .Send command, even when
the target Peer is down.

How can I reliably test to see if the target Peer is up and connected?

(By the way Winsock.State never returns 'sckConnected' when using UDP.
It only returns sckClosed or sckOpen, and this state does not change when the
target Peer goes down unexpectedly.)

THANKS!
Reply With Quote
  #2  
Old 11-04-2010, 03:09 PM
PlausiblyDamp's Avatar
PlausiblyDampA different Winsock problem PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

UDP isn't a connection orientated protocol, this means when two computers are communicating they aren't maintaining a direct link and as such there is no way to detect a peer going offline.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 11-04-2010, 03:16 PM
wayneh wayneh is offline
Centurion
 
Join Date: Mar 2004
Posts: 123
Default

So then it would be better to use a TCP connection, and then use .connect, .close, etc?

As well, the .State should be accurate too?

My only concern is my app is peer-to-peer - I didn't think that could be done with TCP?

Last edited by wayneh; 11-04-2010 at 03:25 PM.
Reply With Quote
  #4  
Old 11-04-2010, 06:04 PM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 645
Default Follow Link...

If you haven't read here recently, [VB6 and API] - learning mutliplayer games

I also made a winsock sample there, you can connect to multiple peers and it is explained shortly after the attachment.
__________________
ZaCkO ... Who is your attitude?
Reply With Quote
  #5  
Old 11-04-2010, 09:05 PM
wayneh wayneh is offline
Centurion
 
Join Date: Mar 2004
Posts: 123
Default

Here's my issues:

1) With TCP, you have to choose if you want a given Socket to be Server or Client.
So if you have 3 machines on a network, and each one starts the app without first knowing which one will be the Server, then you can't properly setup 3 sockets to have peer-to-peer.

2) There is no 'broadcast' mode so if you want all peers to receive the same message, you'd have to loop the send.

Any ideas?

The only potential solution I've seen is to use one Winsock control set to UPD for broadcasting (and initiating connections), and then an array of Winsock TCPs.......
Reply With Quote
  #6  
Old 11-04-2010, 09:26 PM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 645
Default Well

From my understanding, you have to connect to a server anyway. 3 Clients open your program and it connects to a server ip, or each other individual with their ip addresses (but they would have to tell someone their ip, so basically you need a server anyway to connect them altogether). That's why we have a server list for video games. And for torrents same goes, there is a server first. I don't think you can pass this other concept. How do you connect to something you can't see?
__________________
ZaCkO ... Who is your attitude?
Reply With Quote
  #7  
Old 11-05-2010, 08:31 AM
wayneh wayneh is offline
Centurion
 
Join Date: Mar 2004
Posts: 123
Default

Well thanks for your advice anyway.
I'll keep plugging away....
Reply With Quote
  #8  
Old 11-05-2010, 12:12 PM
dilettante's Avatar
dilettanteA different Winsock problem dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,520
Default

There is no broadcast or discovery mechanism for TCP, so you'd have to build that.

One alternative is for each machine to be a server as well as a client to all peers. Your program would listen on some predefined port number and wait for incoming connections. When it "discovers" a new peer it would connect to that peer unless the peer is already connected.

Discovery can be accomplished by sending a UDP broadcast when the program first starts and settles, as well as awaiting any incoming broadcasts from peers. These broadcast messages basically say "I'm here!" and should include the host name or IP address.

A TCP disconnect will tell you when a peer shuts down. Keep in mind that if a peer machine locks up or loses network connectivity it may take as long as 4 minutes for your program to be notified.


An alternative might be to use a "presence server" of some sort. When a peer starts up it would update its entry there, and enumerate the other peer entries there and connect to each of them.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
A different Winsock problem
A different Winsock problem
A different Winsock problem A different Winsock problem
A different Winsock problem
A different Winsock problem
A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem A different Winsock problem
A different Winsock problem
A different Winsock problem
 
A different Winsock problem
A different Winsock problem
 
-->