Main Site Documentation

SocketException ErrorCode 10035


#1

I’m using a FEZ Cobra board, passing in the following parameter values to this function:

[line]

server = "stream.twitter.com"
port = 80

[line]

       private static Socket ConnectSocket(String server, Int32 port)
        {
            // Get server's IP address.
            var hostEntry = Dns.GetHostEntry(server);

            // Create socket and connect to the server's IP address and port
            var socket = new Socket(AddressFamily.InterNetwork,
                                    SocketType.Stream, ProtocolType.Tcp);
            socket.Connect(new IPEndPoint(hostEntry.AddressList[0], port));

            return socket;
        }

[line]

The “socket.Connect” function is throwing this error:

#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (5) ####
#### Message: 
#### Microsoft.SPOT.Net.SocketNative::poll [IP: 0000] ####
#### System.Net.Sockets.Socket::Poll [IP: 0011] ####
#### System.Net.Sockets.Socket::Connect [IP: 0029] ####
#### CobraConsole.WebClient::ConnectSocket [IP: 001b] ####
#### CobraConsole.WebClient::GetContent [IP: 000c] ####
#### CobraConsole.Program::StartMonitoring [IP: 0029] ####
#### SocketException ErrorCode = 10035
#### SocketException ErrorCode = 10035

A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10035
An unhandled exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll

[line]

Any ideas why I’m getting a socket exception?
I’m thinking it has something to do with Twitter not accepting the connection, but not sure.


#2

Can you use code tags please? See note #3 when you submit a post.


#3

The problem was that twitter’s stream service blocks HTTP/port 80 traffic. Instead you have to connect over HTTPS on port 443.


#4

So the next question is how do I send a request over HTTPS?

I noticed someone else is having trouble using SSL:
http://www.tinyclr.com/forum/21/4832/#

I also noticed he was referencing a class called

SslSocket

, what library is that in?


#5

I think there are couple examples in “my documents” folder.

If this is for twitter, there is some code already by the community.