I wrote this simple code to send a string to a client, once it attached to my listen:
  | ||||||||||||||
The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Community Stats
1
Neutral
User ToolsFriendsclaudio.serio hasn't added any friends yet. Latest VisitorsTopics I've StartedSimple send by Socket11 January 2016 - 04:18 PM I wrote this simple code to send a string to a client, once it attached to my listen:
Module Module1
Dim Listen_Thread As Thread
Dim Client_Thread As Thread
Private Listener As System.Net.Sockets.Socket
Private ClientSocket As System.Net.Sockets.Socket
Private bmsg() As Byte
Sub Main()
' write your code here
Dim Msg As String = "This is a transmission test to check the first message. I hope it arrives safety and quickly .... bye bye !"
Dim sMsg() As Char = Msg.ToCharArray
ReDim bmsg(sMsg.Length - 1)
Dim i As Integer
For i = 1 To sMsg.Length
bMsg(i - 1) = CByte(Microsoft.VisualBasic.Strings.AscW(sMsg(i - 1)))
Next
Listener = New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)
Dim ListEndPoint As New System.Net.IPEndPoint(System.Net.IPAddress.Any, 5001)
Listener.Bind(ListEndPoint)
Listener.Listen(1)
Listen_Thread = New Thread(AddressOf listener_thread)
Listen_Thread.Start()
End Sub
Private Sub listener_thread()
While (True)
Try
ClientSocket = Listener.Accept
Debug.Print("Client accepted ")
Client_Thread = New Thread(AddressOf Clienter_thread)
Client_Thread.Start()
Catch ex As System.Net.Sockets.SocketException
Debug.Print("Error, not connected .. : " & ex.Message)
If Not Client_Thread Is Nothing Then
Client_Thread.Abort()
Client_Thread = Nothing
End If
End Try
End While
End Sub
Private Sub Clienter_thread()
While (True)
Dim MessReady As Boolean = False
Thread.Sleep(1000)
Debug.Print("bytes send")
ClientSocket.Send(bmsg)
End While
End Sub
End Module
Then i run and opened HyperTerminal
It works for a while ... then in Hyperterminal i receive a lot of characters and it stop.
You can check simply with Hyperterminal ... i Can't find where is the problem ...
Any Help, please ?
Thanks a lot
N3 Ethernet - it doesn't work01 November 2015 - 08:45 AM From the Contact page in the website
Contact Please drop by our community forums. Join us. A whole community of makers and engineers is here to support you.
.... but in the last month i didn't find anyone that helped me
I've the same problem. I wrote a code for N2 that work and now it doesn't work on N3.
I have only one request .... can anyone try this code for me to make me know if is my hardware that doesn't work or ...... i made a wrong purchase with my N3
The code is the same of the last 4 posts and it works on N2 to set a static address in the setup Can anyone try this .... ??
Dim Interf = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()(0)
Dim DNS(1) As String
DNS(0) = "193.206.115.20"
'DNS(1) = "193.206.115.20"
Interf.EnableStaticIP("192.168.1.111", "255.255.255.0", "192.168.1.1")
This gives a generic error
Ethernet setting ... again26 October 2015 - 04:33 PM Can Anyone try this code with N3 ... please ... i'm going slightly Med
Dim Interf = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()(0)
Dim DNS(1) As String
DNS(0) = "193.206.115.20"
'DNS(1) = "193.206.115.20"
Interf.EnableStaticIP("192.168.1.111", "255.255.255.0", "192.168.1.1")
Ethernet setting22 October 2015 - 02:30 PM Hi everyone,
Can someone explain me how set a static Ip address by code on Netduino 3 Ethernet ?
Thank you Ip Address Netduino 3 Ethernet17 October 2015 - 09:01 AM Hi everyone,
Can someone explain me how set a static Ip address by code on Netduino 3 Eternet ?
Thank you
| ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||