473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.AddressList(0)
Dim remoteEP As New IPEndPoint(ipAddress, port)

' Create a TCP/IP socket.
client = New Socket(AddressFamily.InterNetwork, _
SocketType.Stream, ProtocolType.Tcp)

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

however when I change the first line to the following:

Dim ipHostInfo As IPHostEntry = Dns.GetHostByAddress("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.sockets.socketexception: 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.gethostbyaddress(IPAddress address)
at system.net.dns.gethostbyaddress(string address)
at chat.tech..ctor((frmchat&frm)
I tried changing the first the line to the following

Dim ipHostInfo As IPHostEntry =
Dns.GetHostByAddress(Net.IPAddress.Parse("192.168. 1.2"))
got the same error message above

I also tried the following code:
Dim ipAddress As IPAddress = Net.IPAddress.Parse("192.168.1.2")
'ipHostInfo.AddressList(0)
Dim remoteEP As New IPEndPoint(ipAddress, port)

' Create a TCP/IP socket.
client = New Socket(AddressFamily.InterNetwork, _
SocketType.Stream, ProtocolType.Tcp)

' Connect to the remote endpoint.
client.BeginConnect(remoteEP, AddressOf ConnectCallback,
client)
connectDone.WaitOne()

I got the following error

system.net.socket.socketexception: 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.sockets.socket.endconnect(iasyncresult asyncresult)
at chat.tech.connectcallback(iasyncresult ar)

Am I missing anything?

Thanks
Nov 21 '05 #1
2 2510
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
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>...
4
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
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...
4
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...
4
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...
4
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
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...
6
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...
0
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...
16
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':...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...

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.