Sockets and OLD winsock
Sockets and OLD winsock
Sockets and OLD winsock
Sockets and OLD winsock
Sockets and OLD winsock
Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock
Sockets and OLD winsock Sockets and OLD winsock
Sockets and OLD winsock
Go Back  Xtreme Visual Basic Talk > > > Sockets and OLD winsock


Reply
 
Thread Tools Display Modes
  #1  
Old 01-11-2006, 10:43 AM
CyberDogg CyberDogg is offline
Centurion
 
Join Date: Jun 2004
Posts: 189
Default Sockets and OLD winsock


OK I have a problem with sockets

This code returns that the remote system did not respond:
Code:
Dim mClient As New System.Net.Sockets.TcpClient
        mClient.Connect(strHost, intPort)
I got ****ed off trying to get this to work so I went back to winsock and tried that so I had
Code:
Private WithEvents mTCPZebra As New MSWinsockLib.Winsock
Private Sub OutboundConnection()
        mTCPZebra.Protocol = MSWinsockLib.ProtocolConstants.sckTCPProtocol
        mTCPZebra.Connect("10.179.88.45", 9001)
        Do While mTCPZebra.State = 6
            strState="Connecting..."
        Loop
    End Sub
This never leaves State 6.

So getting more annoyed I went back to VB6 added a winsock control, set the Protocal in propertys, and added the followin code.
Code:
Private Sub Form_Load()
    sck.Connect "xxx.xxx.xxx.xxx", 9100
End Sub
And it worked

can any1 tell me wat i am doing wrong in .NET please
Reply With Quote
  #2  
Old 01-12-2006, 05:16 AM
Sonreir's Avatar
Sonreir Sonreir is offline
Contributor
 
Join Date: Jul 2004
Location: Hampshire, England
Posts: 540
Default

In your .NET attempt it appears you are trying to use a string to connect to another computer. As you probably know, this is looking for a hostname or URL. Not an IP address. If you want to connect to a specific IP address, use the System.Net.IPAddress object.
Reply With Quote
  #3  
Old 01-12-2006, 06:34 AM
CyberDogg CyberDogg is offline
Centurion
 
Join Date: Jun 2004
Posts: 189
Default

Yea in the sockets example i get
Additional information: No connection could be made because the target machine actively refused it

This is if I use a hostname or an IP address.

The winsock example should be fine as it takes an IP address.

I know I am able to connect to the resource via VB6 and Hyperterminal. But not in .NET, and as I dont really want to have to write this app in VB6 (Its a service urgh) I need some help
Reply With Quote
  #4  
Old 01-12-2006, 08:28 AM
Sonreir's Avatar
Sonreir Sonreir is offline
Contributor
 
Join Date: Jul 2004
Location: Hampshire, England
Posts: 540
Default

Prolly a bit obvious, but is your server listening on that port for a connection? If it's not, then it won't accept your connection.

Also, what is the value for strHost in your first example when you run it?
Reply With Quote
  #5  
Old 01-12-2006, 08:48 AM
CyberDogg CyberDogg is offline
Centurion
 
Join Date: Jun 2004
Posts: 189
Default

Yea the server is listening. Otherwise the app in VB6 wouldnt work, or Hyperterminal...

I have tried strHost as an IP and as a fully qualified DNS name i.e device.domain.com both come back with the same issue. Connect should work with either even if u dont use IPAddress.
Reply With Quote
  #6  
Old 01-12-2006, 09:25 AM
Sonreir's Avatar
Sonreir Sonreir is offline
Contributor
 
Join Date: Jul 2004
Location: Hampshire, England
Posts: 540
Default

Well you could always try it as an IPAddress object. That's what I've used in the past and I've not had any problems.
The only time I've ever used the string arguement is when I was using the WINS name for a computer on the local network here.
Reply With Quote
  #7  
Old 01-12-2006, 09:38 AM
CyberDogg CyberDogg is offline
Centurion
 
Join Date: Jun 2004
Posts: 189
Default

I have tried that still no joy... Just cant believe .NET cant do it if VB6 can...
Reply With Quote
  #8  
Old 01-12-2006, 10:31 AM
Sonreir's Avatar
Sonreir Sonreir is offline
Contributor
 
Join Date: Jul 2004
Location: Hampshire, England
Posts: 540
Default

Either can I. I say keep at it. Something is going wrong somewhere.
Reply With Quote
  #9  
Old 01-12-2006, 10:35 AM
reboot's Avatar
rebootSockets and OLD winsock reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

My guess would be pebcak. Obviously vb.Net can do anything VB6 can do. You just haven't figured out how.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #10  
Old 01-13-2006, 03:10 AM
CyberDogg CyberDogg is offline
Centurion
 
Join Date: Jun 2004
Posts: 189
Default

Quote:
Originally Posted by reboot
My guess would be pebcak. Obviously vb.Net can do anything VB6 can do. You just haven't figured out how.
tbh I find that a little insulting. I know VB.NET should be able todo anything VB6 can, that is why I am getting so frustrated with this issue and asking for someones help, If you dont know why post? I thought thats what this forum is for...

In VB.NET I have written a load of apps that use sockets. Client/server, Client only and FTP. So its not like my code is wrong, I have used this code before and it works while connecting to an FTP server and works while connecting to a server I have written. It just wont connect to this network device, but VB6 can? And then using WINSOCK in VB.NET in the same way you would in VB6 and still it doesnt work? doesnt that strike you as a bit odd?
Reply With Quote
  #11  
Old 01-13-2006, 08:08 AM
PrOpHeT's Avatar
PrOpHeTSockets and OLD winsock PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default

Have you tried debugging from a server perspctive? AKA, write a simple server or use netcat to see if the request for connection is even being attempted to the remote side?
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
  #12  
Old 01-13-2006, 08:57 AM
reboot's Avatar
rebootSockets and OLD winsock reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

I don't know much about sockets; I mainly write database apps. I do know if I try to write a database app in .Net using vb6 logic it would not work at all. Many, many things changed drastically in .Net. I sense your frustration, and I'm just trying to point out that blaming .Net is not very productive.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #13  
Old 02-02-2006, 01:40 PM
W_Garabrandt W_Garabrandt is offline
Centurion
 
Join Date: Mar 2004
Location: Altoona, PA USA
Posts: 139
Default

OK, I see what the problem here is.
When you create the socket (in the original example) you are not
1) Binding it to an adapter (so the default may not be the one you want)
2) Are not resolving the address to a real address. Try Dns.Resolve for that
3) Not instantiating the socket properly.

I strongly recommend searching the forum for examples of how this is done. I've posted several in-depth examples that could be a lot of help for you.

Here's How to host:
Server Client App
And Here's how to listen
winsock driving me crazy!!!
(You will have to scroll down a bit to read my post on them, but it should help you a lot.)
__________________

I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking
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
Sockets and OLD winsock
Sockets and OLD winsock
Sockets and OLD winsock Sockets and OLD winsock
Sockets and OLD winsock
Sockets and OLD winsock
Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock Sockets and OLD winsock
Sockets and OLD winsock
Sockets and OLD winsock
 
Sockets and OLD winsock
Sockets and OLD winsock
 
-->