socket problem

N

n30 [Dzej O.]

Hi
I ve got small problem with the "connect"
I made a application waiting for a connection and for a data.
And I written in VS 2005 ap rogram w pocket pc.
Program is working good on the Pc. The problem is that is crashing down
on the pocket.
I tried to use 2 difrent ways to connect:

TcpClient klient = new TcpClient();
klient.Connect(IPAddress.Parse("192.168.1.19"),
int.Parse("6667"));
NetworkStream stream = klient.GetStream();
BinaryWriter w = new BinaryWriter(stream);
w.Write("MSG!");

********************************************************
And:

********************************************************
Socket s = null;
IPEndPoint ipe = new
IPEndPoint(IPAddress.Parse("192.168.1.19"), int.Parse("6667"));
Socket tempSocket = new Socket(ipe.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);

tempSocket.Connect(ipe);

if (tempSocket.Connected)
{
s = tempSocket;
}

string Data_to_send = "MSG!!";
Byte[] bytesSent = Encoding.ASCII.GetBytes(Data_to_send);
s.Send(bytesSent, bytesSent.Length, 0);

*************************************************************
in details after crash on pocket pc in first lines i see problem with
the connect method. Can someone help me?


regards!
Ps. Sorry for language mistakes, EN is not my native.
 
N

n30 [Dzej O.]

Simon Hart [MVP] pisze:
What exception are you getting if you are getting an exception.


In translation from my native:

Error msg cannot be displayed becouse there is no resources with that msg.


in:
Syste.net.socket.nocheck()

in:
Syste.net.socket.connect()


....

in DeviceApplication1.Program.Main()

....


I belive that problem is in compact framework on the pocket pc.
tha package propably do not have the connect method.
B ut this theory is failing when i delete the code from line with
connect method.
So class Socket is impleted to the CF, and I don't beleive that someone
putted Socket class without connect method...


Regards.

Ps. Sorry for Language mistakes.
 
P

Peter Foot

connect is definitely implemented in Socket. You need to determine the type
of the exception that occurs, the fact that there isn't a message isn't the
root issue. Can you check (e.g. with Internet Explorer Mobile) that you have
network connectivity and that you can reach this particular host, also make
sure you don't have any firewalls etc in between. If you are testing this
through an ActiveSync passthrough connection you'll probably find this is
not letting traffic through on that port, you should try on a direct e.g.
WiFi network.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility
 
N

n30 [Dzej O.]

Peter Foot pisze:
connect is definitely implemented in Socket. You need to determine the
type of the exception that occurs, the fact that there isn't a message
isn't the root issue. Can you check (e.g. with Internet Explorer Mobile)
that you have network connectivity and that you can reach this
particular host, also make sure you don't have any firewalls etc in
between. If you are testing this through an ActiveSync passthrough
connection you'll probably find this is not letting traffic through on
that port, you should try on a direct e.g. WiFi network.

Thx your advice solved problem out!
I used the connecion form active sync.
When I enabled Wifi network thep roblem is gone!

Thx a milion!
Regards!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top