Netduino home hardware projects downloads community

Jump to content


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.

PawleysPlayr

Member Since 26 Apr 2011
Offline Last Active Jul 12 2011 01:37 PM
-----

Posts I've Made

In Topic: Thermistor Help

03 June 2011 - 11:34 AM

Thanks! I guess you're right. I should pick up a thermister with the temp/R data on the datasheet. I would be interested in taking a look at you c solution. Just to verify what I've done.

In Topic: Getting the local IP address

02 June 2011 - 12:37 PM

If you create a socket, does the IP show up in the Socket.LocalEndPoint property?

In Topic: System.Math problem

02 June 2011 - 11:39 AM

Thanks Mario!

In Topic: Beginner Question and Hello!

26 May 2011 - 09:23 PM

The RAM was fine...+40K. Turns out there is something screwy going on with the sockets collection. In the SendNewData Method the RemoteEndpoint is getting changed at the item.Send ie this code: Debug.Print(item.RemoteEndPoint.ToString()); item.Send(bytesSend); Debug.Print(item.RemoteEndPoint.ToString()); Result: "10.10.10.106:56890" at the first debug statement then "8.5.0.0:0" or something similar at the second debug statement So the next time the SendNewData was called, that invalid RemoteEndpoint would throw an exception. I have no idea what is happening there. In the short term ... just so I can move forward ... I've changed the code to save an arraylist of string IP addresses. It works fine, but now I have to create a new socket for each client and connect before I can send the next message. Just seems like it would be better to keep the socket intact once it's connected. I don't know anything about how sockets and their connections really work. I was just assuming the connections were persistant. Is that not the case?

In Topic: Beginner Question and Hello!

24 May 2011 - 02:00 PM

Ok...I'v made some headway, but now I need a little help. There's something screwy about the way I'm using the socket send method. The problem is: When the program runs item.Send(bytesSend); in the SendNewData method I get the errors I've copied from my immediate window below. What I'm trying to do is create a list of socket clients that are registered to receive messages. When a client registers, I open the socket connection and add that socket to the arraylist of sockets. At timed intervals the SendNewData method is called. My idea was for it to loop thru the list of sockets and send the data to each one. Any ideas? private static ArrayList _registeredClients = new ArrayList(); private void _addClientSocket(string ip) { //create the socket...test the connection...add the socket to _registeredClients arraylist try { // Create a socket connection with the specified server and port. Socket tempSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); tempSocket.Bind(new IPEndPoint(IPAddress.Any, _sendPort)); tempSocket.Connect(new IPEndPoint(IPAddress.Parse(ip), _sendPort));// try to connect if (tempSocket != null)// is the socket connected? { // add the new socket to the clients arraylist. _registeredClients.Add(tempSocket); } } catch (SocketException e) { Debug.Print(e.Message.ToString()); } } public void SendNewData(string AINData) { if (_registeredClients.Count > 0)//Make sure there are clients to send to { Byte[] bytesSend = Encoding.UTF8.GetBytes(AINData);//convert the string to byte array as required by socket.send method foreach (Socket item in _registeredClients) { if (item != null) { Debug.Print(item.RemoteEndPoint.ToString()); item.Send(bytesSend); } } } } Immediate Window: 10.10.10.106:56890 #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (4) #### #### Message: #### Microsoft.SPOT.Net.SocketNative::connect [IP: 0000] #### #### System.Net.Sockets.Socket::Connect [IP: 001d] #### #### ClientCommHandler.CClientHandler::SendNewData [IP: 005f] #### #### ClientCommHandler.CTrafficCop::SendNewData [IP: 000d] #### #### DLogger.Program::_thermistorHandler_NewTemperaturesHandler [IP: 000b] #### #### ThermistorInterface.CThermisterHandler::SendTemperatures [IP: 001c] #### #### ThermistorInterface.CThermisterHandler::UpdateTemperatures [IP: 0028] #### #### SocketException ErrorCode = -1 #### SocketException ErrorCode = -1 A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll #### SocketException ErrorCode = -1

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.