BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-12-2009, 04:05 PM   #1 (permalink)
New Member
 
Join Date: Oct 2009
Model: 8900
PIN: N/A
Carrier: none
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Socket Programming

Please Login to Remove!

hi,

I am using Client/Server socket ( or Stream) Connection were it transfer data between both Client and Server, but the Client's socket cannot be opened. so how can i solve it???


Client code:


StreamConnection connection = (StreamConnection) Connector.open("socket://IP:PORT",Connector.READ_WRITE);

InputStreamReader isr = new InputStreamReader(connection.openInputStream());

OutputStreamWriter osw = new OutputStreamWriter(connection.openOutputStream());

osw.write(215);
osw.flush();



Server code:


server = new ServerSocket(7777, 2000);

socket = server.accept();

is = socket.getInputStream();
os = socket.getOutputStream();

int x = is.read();
Offline  
Old 11-12-2009, 05:20 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Hard to say how to solve it if you don't say what the issue is.

I don't see any connection parameter attached to your URL, so is this a BES device?

If not, you need to review the available literature on making HTTP connections and repost your question with more info.
Offline  
Old 11-13-2009, 06:29 AM   #3 (permalink)
New Member
 
Join Date: Oct 2009
Model: 8900
PIN: N/A
Carrier: none
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default answer

hi,

Thanks for reply, the URL= IP address:port number, and I'm using Blackberry device and BB internet service connection. Moreover, as you see i am using socket or stream connection not HTTP connection.
Offline  
Old 11-13-2009, 07:44 AM   #4 (permalink)
New Member
 
Join Date: Oct 2009
Model: 8900
PIN: N/A
Carrier: none
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default answer

I forget to told you that I'm using a device not Emulator.
Offline  
Old 11-13-2009, 09:04 AM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

If by BB internet service you mean BIS, then that is your problem. Unless you are an alliance member with access to BIS-B, the BIS will only support http connections. To use a TCP/IP socket you have to use direct TCP through your wireless provider, or via Wi-Fi.

See this video.
__________________
My other Blackberry is a PlayBook.

Last edited by hrbuckley : 11-13-2009 at 09:05 AM.
Offline  
Old 11-13-2009, 05:35 PM   #6 (permalink)
New Member
 
Join Date: Oct 2009
Model: 8900
PIN: N/A
Carrier: none
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default answer

So, Can you show me how to convert my attached code previously to be HttpConnection because I didn't deal with this type of connection before,please??
Offline  
Old 11-13-2009, 07:35 PM   #7 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Take a look at the HTTPDemo applicaiton that ships with the JDE.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.