Udp socket send but can not receive data

653 views
Skip to first unread message

Nguyen Nghi

unread,
Feb 10, 2011, 4:23:29 AM2/10/11
to android-ndk
Dear all,

I am developing a sample client/server on android. This sample working
as follow:

A server is running on Android device ( HTC-HD2) and a client is
running on development desktop machine ( Running WinXp2).
HTC-HD2 using wifi network and have IP is ( 192.168.0.115). My desktop
machine using IP ( 192.168.11.87).

Server create 2 thread :
1. Receiving thread: open a socket on port
( 27000) and receive data from desktop machine
2. Sending thread: create a socket and send
data to port 64000

Client create 2 thread: One thread receive data on local socket, and
the other send data to HTC-HD2(192.168.0.115)


Both 2 sockets is created by C++ and is called through JNI. But
"Receiving thread" can not receive data on 27000 port and "Sending
thread" send data normallly. ( I used wireshark on desktop machine to
capture data,I see that, HTC-HD2 using IP 192.168.0.2 ( IP address of
router) to sending data and have data sent to port 27000 and ip
192.168.0.115).

I haved used sipdroid as a sample to contact with sipclient on deskop
and see that 2 way data is received and sent normally.

So I think that have a problem on JNI socket. ( using open source
http://code.google.com/p/destroyallhumans/source/browse/trunk/JAVA/Netcat/jni/OSNetworkSystem.cpp?spec=svn18&r=18).

Please help me to solve this problem.

Thanks in advanced.











alan

unread,
Feb 10, 2011, 10:04:13 AM2/10/11
to andro...@googlegroups.com
unless you really need to use a java socket you may have more success talking directly to the bsd sockets api

Nguyen Nghi

unread,
Feb 10, 2011, 9:13:33 PM2/10/11
to android-ndk
May be this problem relate to NAT?
I have spent too much time for debug, and see that select() function
return 0 ( no data is comming ), but I sure that have data comming to
this port on my device.

Anyone can help me for this problem. Thanks so much.
Reply all
Reply to author
Forward
0 new messages