Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
kumaresan
Posts: 183
Registered: ‎12-17-2008
My Device: 8320

server/client communication

Hi all,

 

i done my client side part of the socket connection....

 

now i want to develop server side code...

 

concept is, if i start serverside, it will listening in background any client is connect or not?

 

my question is if suppose any client will open the socket connection,

 

how can i find out in server side...

 

can i check with port number Or some else????

 

so plz solve my problem...

 

 

 

kums

******************************

Press kudos which the post help you
Please mark posts as solved if you got a solution
Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: server/client communication

I'm not sure what you are asking here.  What are you trying to find out on the server side?  If you are looking for a way to uniquely identify the user you can use the BlackBerry PIN.  Your application can access this by using the DeviceInfo class.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: server/client communication

If you want to set up a ServerSocket and let others discover your existence and connect over a carrier,

you need a high-level blessing...

See my earlier rants on this.

Actually, since you can't even connect to 127.0.0.1 I don't think you can be a server on wifi either

but not sure how you specify an interface here and if it would have any impact. In any case, inability

to get a static IP makes this of limited usage. Try bluetooth for local exchanges.

 

 

 

Please use plain text.
Developer
amardeepjaiman
Posts: 293
Registered: ‎02-25-2009
My Device: Not Specified

Re: server/client communication

Hi marchywka,

 

I have the same kind of requirement. I just want open a serversocket connection on BB device. and want to connect desktop application to this serversocket using USB cabel or Wifi. 

 

But same problem is facing me too, i dont get a static IP Address from BB device server socket. so i dont know which host , my client on desktop has to connect . please suggest me something.

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: server/client communication

political action? This is purely a business issue...

opposing  viewpoints welcome but AFAIK that is the case.

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: server/client communication

[ Edited ]

Edit:  This post was written under the assumption the Original Poster wanted to open a Server Socket on the BlackBerry device, as opposed to a socket to a Server on the BlackBerry Client device.  On re-reading, I think I have misinterpreted the question.  If the Poster was asking about connecting a Client socket to a Server PC, then this Post should be ignored. 

 

..... 

 

Here are some thoughts:

 

Ignore WiFi for the moment.

 

On a wireless (non WiFi) connection, the BlackBerry device is not actually known on the Internet.  It has some proxy (gateway) points that it goes through.  These gateways have been designed to provide Internet access to the device, rather than provide access from the Internet to the device. 

 

I think this is like a NATing router, like the one I have at home.  To the world, there is only one IP address associated with my house.  However all the home PC's use it.  Now in this situation at home, it is not possible to set up a Server PC in my home network, unless I do something clever with the router to let the world in to that Server PC.

 

So if you try to set up a Server on your wireless (non WiFi) BlackBerry, you need to do something similar to the gateway, so that users on the other side of the gateway can actually send stuff to you, and you have to have some 'address' that is known to them. 

 

You always have been able to have a BlackBerry act as a Server in an MDS environment.  In this case, in a message you wish to send, you identify the target device using its email address or pin, and the MDS can route this through to the device. Shortly, or may even be now, you will be able to do this to devices over BIS-B.  But, as I understand it, you have to send a special message to MDS or the BIS-B proxy Server, which identifies the target device and attributes of the message.  This is nothing like a standard TCP connection request to a TCP/IP address and I don't see how it ever could be.

 

So in the case of wireless (non WiFi) connections, I don't think political action, business issues or anything else is going to help.  I just don't see how the infrastructure will ever support it.


Now on to WiFi.

 

It does seem like it should be possible to have WiFi device listen for connections on a specific port, because it actually has an IP address, so other devices can identify it.  But I can also see that the implementation of WiFi might not be as full as it is on the PC - a bit like the wireless implementation it might be outgoing and not incoming.  This is something I have meant to try for ages.  But at this time, I can't really comment on how it may or may not work as a Server. 

 

However I'm not sure how useful a Server on a WiFi BlackBerry would be?  How useful is a Server on a WiFi only laptop PC that gets taken around the country? 

 

Message Edited by peter_strange on 06-10-2009 09:09 AM
Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: server/client communication

This is really a non-technical issue for the most part, not to make any villians or point to any witches

but everything you mention is already possible and being done with the right rate plan and names.

 

I would make a couple of points of course. At home, you can call the cable company and get

a static IP- they make you buy business service but just be thankful you can read news that doesn't support the

cable company :smileyhappy: ( I'm being facetious but open access has been a real problem- the Chinese are now

protecting people from certain thoughts ... ). I can set up apache in my living room as long as Comcast gets

their cut. 

 

 How is it that phone companies can let you send SMS messages to a phone without knowing where it is?

Yet SMS happens. IP addresses and machine names can move just as well. If the carriers can route your

call they can route arbitrary digital stuff. Is SMS useful? Why not my own server to listen for my own requests

or data pushes?

 

Now,  clearly someone needs to pay for all this stuff and I'm not making any villians but you can understand that

all this stuff is reasonably possible but various non-technological issues are probably the limitation in this case.

 

Although, I must confess I don't know anything about Nine Inch Nails but I have a strange desire to build 

an app for them, LOL...

 

http://news.cnet.com/apple-rejects-nine-inch--nails-iphone-app-update/

 

 

 

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: server/client communication

[ Edited ]

Edit:  This post was written under the assumption the Original Poster wanted to open a Server Socket on the BlackBerry device, as opposed to a socket to a Server on the BlackBerry Client device.  On re-reading, I think I have misinterpreted the question.  If the Poster was asking about connecting a Client BlackBerry socket to a Server PC, then this Post should be ignored.

 

.....

 

Let us actually answer the poster's question before we digress into what is possible.

 

The posters last questions were:

 

"I have the same kind of requirement. I just want open a serversocket connection on BB device. and want to connect desktop application to this serversocket using USB cabel or Wifi. 

 

But same problem is facing me too, i dont get a static IP Address from BB device server socket. so i dont know which host , my client on desktop has to connect . please suggest me something."

 

USB won't work, it doesn't provide TCP connectivity. 

 

WiFi might enable the BB to act as a Server (as noted, something I haven't tested) but even if it did, no WiFi enabled BlackBerry device that I have has the possibility to fix its IP address.

 

Is there any reason why the Blackberry device could not connect to the Desktop - couldn't the Desktop have a static IP address?

 

Now marchywka, back to our discussion!  I agree that it is possible to change the existing network and do what you want.  But to do it would require that all phones become IP Savvy and the carrier companies provide DNS equivalent Servers to match phone numbers to IP addresses. 

 

You say:

1) "At home, you can call the cable company and get a static IP".  For me that isn't enough.  I still have to change the router to forward a port to the PC I want to connect to.  My home PC does not have an Internet address.  In the mobile world, the carriers gateway replaces the natting router, and the mobile devices replace the PC's, the problem is connecting from the internet side of the gateway to a mobile device.

2) "How is it that phone companies can let you send SMS messages to a phone without knowing where it is?"  Because they designed their networks and the associated packets to do this.  Extending this connectivity to handle full TCP is a lot of work!

 

I think we both agree it is possible.  But what is the benefit?  How useful is a BlackBerry (or other mobile phone) Server?  Why would anyone create a Blackberry (mobile phone) Server, when they can create a PC Server?

 

 

Message Edited by peter_strange on 06-10-2009 09:10 AM
Please use plain text.
New Developer
richardschillin
Posts: 17
Registered: ‎05-01-2009
My Device: Not Specified

Re: server/client communication

As was mentioned, if you write your server so that it opens a port and then listens to incoming blackberry connections, you'll be fine.  That handles blackberry -> server communications.  To know if it's actually a blackberry connecting to your server, you need to create a simple protocol so that the blackberry can identify itself to your server.

 

To get your  server to connect to the blackberry (without using the enterprise services), then you can do this in a number of ways.  A simple way is using SMS push.  Have your server send a small amount of data in an SMS message that is directed to a specific port.

 

Then the phone can read the message, and send a response back to the server.

 

Hope that helps.

 

Richard Schilling

Root Wireless, Inc.

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: server/client communication

I think I have completely missed the point of this.  I had assumed that the Poster wanted to open a Server Socket on the BlackBerry, in other words to use the BlackBerry device as a Server.  Now that I read it again, I see that the Poster may have actually wanted to open a socket to the Server, in other words, open a Client socket.  This is a completely different question, and not one I have been answering.  But on reflection I think this is the correct interpretation.  So my posts above should be ignored, what richardschillin says is correct. 

 

Apologies to all for wasting bandwidth answering the wrong question.

Please use plain text.