[RESOLVED] An address incompatible with the requested protocol was used
how can i solve this problem?
Re: An address incompatible with the requested protocol was used
Use an address that is compatible with the requested protocol. For us to tell you any more than that, we'd have to see the code that caused the error, not just the error message.
Re: An address incompatible with the requested protocol was used
i can't fully understand what you are saying cause i'm just a newbie in vb.net.. here's my code
Code:
Imports System.Net.Sockets
Imports System.Text
Imports System.Net.IPAddress
Imports System.Net.IPHostEntry
Imports System.Net
Public Class Form1
Dim clientSocket As New System.Net.Sockets.TcpClient()
Dim serverStream As NetworkStream
Dim ipAddress As IPAddress = Dns.GetHostEntry("localhost").AddressList(0)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim outStream As Byte() = _
System.Text.Encoding.ASCII.GetBytes("Message from Client$")
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()
Dim inStream(10024) As Byte
serverStream.Read(inStream, 0, CInt(clientSocket.ReceiveBufferSize))
Dim returndata As String = _
System.Text.Encoding.ASCII.GetString(inStream)
MsgBox("Data from Server : " + returndata)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox("Client Started")
clientSocket.Connect(ipAddress, 8080)
TextBox1.Text = "Client Socket Program - Server Connected ..."
End Sub
Sub msg(ByVal mesg As String)
TextBox1.Text = TextBox1.Text + Environment.NewLine + " >> " + mesg
End Sub
End Class
can you please tell me what to do? i'm using vista.. ive searched that error in the internet and it says that i'm trying to connect to an IPv6 address / IP without the IPv6 stack installed. i checked the settings of my network connections and i saw that ipv4 and ipv6's checkbox are both checked.. i've tried to install ipv6 on the command prompt.. i typed netsh interface ipv6 install.. but it says that 'the following command was not found: install'
help please..
Re: An address incompatible with the requested protocol was used
Presumably AddressList(0) is an IPv6 address. If you want to connect to the local machine then you may as well just use IPAddress.Loopback.
Re: An address incompatible with the requested protocol was used
finally!!!!!!!!!!!!!
thanks a lot bro!!!
great job!
Re: [RESOLVED] An address incompatible with the requested protocol was used
one more question please..
what if i want to get the ipaddress of another computer? for example, 112.203.80.0 visual studio reads that ipaddress as string so i can't put it in the parameter of tcplistener or socket.connect.. what will i do to convert it to ipadress that the visual studio can read? (not string)
Re: [RESOLVED] An address incompatible with the requested protocol was used
You need to create an IPAddress object, i.e. an instance of the IPAddress class. Read the documentation for that class and you'll find out how to do that. Always read the relevant documentation first.