473,569 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Socket problem

rs
I am writing a client/server program. currently the server and the
client are running in the same computer. the client used to connect
fine to the server with the following code:

Dim ipHostInfo As IPHostEntry = Dns.Resolve(Dns .GetHostName)
Dim ipAddress As IPAddress = ipHostInfo.Addr essList(0)
Dim remoteEP As New IPEndPoint(ipAd dress, port)

' Create a TCP/IP socket.
client = New Socket(AddressF amily.InterNetw ork, _
SocketType.Stre am, ProtocolType.Tc p)

' Connect to the remote endpoint.
client.BeginCon nect(remoteEP, AddressOf ConnectCallback ,
client)

however when I change the first line to the following:

Dim ipHostInfo As IPHostEntry = Dns.GetHostByAd dress("192.168. 1.2")
where 192.168.0.2 is the ip address of the local machine as well
I am getting the following exception
system.net.sock ets.socketexcep tion: the requesed name is valid and was
found in the database, it does not have the correct associated data
being resolved for
at systemm.net.dns .gethostbyaddre ss(IPAddress address)
at system.net.dns. gethostbyaddres s(string address)
at chat.tech..ctor ((frmchat&frm)
I tried changing the first the line to the following

Dim ipHostInfo As IPHostEntry =
Dns.GetHostByAd dress(Net.IPAdd ress.Parse("192 .168.1.2"))
got the same error message above

I also tried the following code:
Dim ipAddress As IPAddress = Net.IPAddress.P arse("192.168.1 .2")
'ipHostInfo.Add ressList(0)
Dim remoteEP As New IPEndPoint(ipAd dress, port)

' Create a TCP/IP socket.
client = New Socket(AddressF amily.InterNetw ork, _
SocketType.Stre am, ProtocolType.Tc p)

' Connect to the remote endpoint.
client.BeginCon nect(remoteEP, AddressOf ConnectCallback ,
client)
connectDone.Wai tOne()

I got the following error

system.net.sock et.socketexcept ion: a connection attempt failed because
the connected part did not properly respond after a period of time or
established connection failed because connected host has failed to
respond
at system.net.sock ets.socket.endc onnect(iasyncre sult asyncresult)
at chat.tech.conne ctcallback(iasy ncresult ar)

Am I missing anything?

Thanks
Nov 21 '05 #1
2 2544
rs
Sorry guys for the silly question. I had the wrong IP address :S
my assigned ip was 192.168.0.2 :S
I have wasted 2 days in such a silly problem

Nov 21 '05 #2
ur code isn't doing nothing...
i suggest u www.pscode.com
search chat in vb.net u will get both server and clinet source code.
regards

rs wrote:
Sorry guys for the silly question. I had the wrong IP address :S
my assigned ip was 192.168.0.2 :S
I have wasted 2 days in such a silly problem


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2642
by: Thomas Hervé | last post by:
My problem is not really python specific but as I do my implementation in python I hope someone here can help me. I have two programs that talk through a socket. Here is the code : <server> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.settimeout(5.0)
4
11738
by: Bryan Olson | last post by:
Here's the problem: Suppose we use: import socket f = some_socket.makefile() Then: f.read() is efficient, but verbose, and incorrect (or at least does not play will with others);
4
2257
by: faktujaa | last post by:
Hi, I am having some problem with callback used in socket implementation. private static void Connect(string strPrtrIPAddr, int intPrtrPort, ref Socket rsocClient) { try { // Create remote end point. System.Net.IPAddress IPAddress = System.Net.IPAddress.Parse(strPrtrIPAddr); System.Net.IPEndPoint IPEndPoint = new...
4
7070
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a incoming connection,the relative code snipprt as following:: private IPAddress myIP=IPAddress.Parse("127.0.0.1"); private IPEndPoint myServer;...
4
18097
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed as I find appropriate. I am using the socket asynchronously by calling the BeingSend and BeginReceive calls. I would like to be able to call...
4
2339
by: Sa¹o Zagoranski | last post by:
Hi! I'm writing a simple 3D First person shooter game. It is a multiplayer game, where all the players connect to one server.
11
8585
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling mechanisms. I use a non-blocking approach for this, using the call to 'poll' to support the async mechanism - rather than the 'begin' and 'end'...
6
3659
by: ahlongxp | last post by:
socket.makefile() may lose data when "connection reset by peer". and socket.recv() will never lose the data. change the "1" to "0" in the client code to see the difference. confirmed on both windows and linux. so I guess there is a problem with makefile(). # Echo server program
0
3561
by: george585 | last post by:
Hello! I am new to network programming, and understand just basics. Using some sample code, and having read documentation, I managed to create a simple app in C# and VB.NET. The application is supposed to do the following: monitor ALL INCOMING TCP traffic on the local computer, and save certain parts of it as files - not log files though, but...
16
3834
by: =?iso-8859-1?q?|-|e|=5F|=5F_B0=DD?= | last post by:
hi all! I got a problem. I declared a SOCKET var in my C program but when i compiled the program it displayed like *--------------------------------------------------------------* *'SOCKET': illegal use of this type as an expression * * C:\..\..\..\include\winsock2.h: see declaration of 'SOCKET' *...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.