socket server problem

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

socket server problem

Postby hrc777 » Sat Jun 13, 2009 10:15 pm

Greetings, everyone.

first of all, this forum is probably the most useful thing i have been using for my work on android (college project).
I required many parts (aspects) of android, and i've found it all very useful right here, so thanks to plusminus and others for helping.

Now, the problem, of course :D

The problem i have is with socket programming, i have been using it a lot in my project, and had no major issues with it, except the latest where i have to make a socket server on android emulator to wait for connections from others (particulary, only from server on the same computer using emulator).
I have read many articles about this issue, but still it's not very clear, the problem is that, after:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         myServer = new ServerSocket(5000);
  2.  
  3.                         //catch exception..
  4.  
  5.                         //some functions..;
  6.  
  7.                         //waiting for server on adroid to accept any incoming connections
  8.  
  9.                         try {
  10.  
  11.                                 connection = myServer.accept();
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


the application just freezes (after the last line of code, when starting to accept connection).
and no errors are reported in the log, it just stops to responding. At the same time, i use a lot socket connecting in the same application (event at the same activity, actually service, that is), but this just doesn't work!

is there a simple and reliable solution for this?, obviously i am missing something important, because only this aspect of sockets doest work. I saw examples where the we should change something in the emulator settings, but what exactly?
I am grateful for any kind of help. if the solution exists on this forum, please point me to it, i've been searching for it for a long time.
hrc777
Freshman
Freshman
 
Posts: 2
Joined: Wed Apr 15, 2009 6:12 pm
Location: Croatia

Top

Postby Vermouth » Sun Jun 14, 2009 9:49 am

The program just WAIT for a connection on 5000.
Then it freeze.

Run this into a thread...
/!\ Bad English Speaker /!\
Tell me if a sentence is not corect :P
Vermouth
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 15, 2009 2:01 pm

Postby hrc777 » Sun Jun 14, 2009 11:04 am

thanks a lot, it works now! :D uh, i obviously forgot about new thread :oops: , because i use all this socket connecting, and never with thread, but it's different with server sockets.
hrc777
Freshman
Freshman
 
Posts: 2
Joined: Wed Apr 15, 2009 6:12 pm
Location: Croatia

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests