Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having problem creating a socket

Status
Not open for further replies.

cipro

Technical User
Apr 27, 2002
50
CA
I am trying to create a socket and I am getting an error on the line:

Dim sock As New Socket(AddressFamily.InterNetwork ,SocketType.Rdm,ProtocolType.Udp)

it says that The support for the specified socket type does not exist in this address family

Can someone please point out where I am going wrong with my code (See Below).

Thanks


Function BroadCastAlarm(ByVal msg)
Const sckTCPProtocol = 0
Const sckUDPProtocol = 1
Dim buffer As Byte()
Dim IP_buff As Byte()
IP_buff = System.Text.Encoding.UTF8.GetBytes("255.255.255.255")
Dim str, nTime
Console.WriteLine("Creating Socket")
Dim end_point As New System.Net.IPEndPoint(System.Net.IPAddress.Parse("255.255.255.255"), 19989)
Dim sock As New Socket( AddressFamily.InterNetwork ,SocketType.Rdm, ProtocolType.Udp)

nTime = fixDate(FormatDateTime(Now), "yyyy-mm-dd") + "T" + fixTime(FormatDateTime(Now), "hh:mm:ss") + "-04:00"
str = "<?xml version=""1.0""?>" + vbCrLf + _
"<NOTIFY_ALL_FORMS xmlns:xsd="" xmlns:xsi="" + vbCrLf + _
" <created>" + nTime + "</created>" + _
" <database_table>@system_alert</database_table>" + vbCrLf + _
" <primary_key_field>" + msg + "</primary_key_field>" + vbCrLf + _
" <primary_key_value>-1</primary_key_value>" + vbCrLf + _
" <notify_Type>UPDATE</notify_Type>" + vbCrLf + _
" <from_host>AJB-ISA</from_host>" + vbCrLf + _
"</NOTIFY_ALL_FORMS>"
buffer = System.Text.Encoding.UTF8.GetBytes(str)
Console.WriteLine("Connecting")
sock.Connect(end_point)
Console.WriteLine("Sending")
sock.Send(buffer)
Console.WriteLine("closing")
sock.Close()
Console.WriteLine("Closed")
sock = Nothing
End Function
 
I have the socket connecting now, but the data I am sending isn't being picked up by any of my listeners on the network (note: I am trying to broadcast traffic)

I made the following changes to my top section of code to get this to work:
Const sckTCPProtocol = 0
Const sckUDPProtocol = 1
Dim buffer As Byte()
Dim str, nTime
Console.WriteLine("Creating Socket")
Dim end_point As New System.Net.IPEndPoint(System.Net.IPAddress.Parse("255.255.255.255"), 19989)
Dim sock As New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top