×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    101

    Implementing a server providing sockets, but where to start

    Hi, I need to add a simple server to my symbian program which shall provide a socket server to accept connections from a J2ME app running on the same phone.

    I read several examples both on forum.nokia.com and in some books concerning sockets but all of them only cover the client side and mention the server side only with a few words like "...implementing a server is much more work than the client....". I didn't even find a clue which class you have to use a basis like RSocket for a client.

    I hope anybody can give me a hint, where to start or maybe to an example which fits my case.


    Cheers
    Simon
    Last edited by schnesim; 2008-07-02 at 15:17.

  2. #2
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: Implementing a server providing sockets, but where to start

    Hi,

    though I have not coded such a thing for a while, I have a vague idea which I think might help you. (Note: these are for connected type connection, I have not much idea on connectionless type)

    Some properties of a server.
    * Server should be written with RSocket itself.
    * First you will need to call Open call. (till here it is same as client code)
    * Now you will need to BIND this to a particular port, as servers always listen on a specific port decided before hand (i am not sure of exceptions to this). The call is RSocket.Bind();
    * Now you will need to call RSocket.Listen();
    * Finally you will need to call Accept(); (Note your class would be an active object, and accept would only return when a connection comes in, otherwise your RunL will not be called till then).
    Also note that, you will need a blank socket (this will hold connection details of the incoming client). Read more at SDK in RSocket.
    * Once a RUNL has been called, you have the blank socket, on this you can call Read and get the data.
    * Also you can call Accept as and when you are done with RunL() to make another request.

    this is very similar to server rules present here for various server in various OS:
    http://en.wikipedia.org/wiki/Berkeley_sockets
    it even talks about UDP (connection less), and can be useful, but I am not sure as I had used them long back.

    you can also have a look at:
    http://www.cs.gsu.edu/~cscqxcx/3320/slides/Sockets.ppt
    slide 6 describes programatically how this happes...

    hope this helps
    Amit Kankani
    Nokia Developer Champion

  3. #3
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    101

    Re: Implementing a server providing sockets, but where to start

    Thx for your tips. I hope they'll help me on.

    I also just found this example on the wiki which covers the server side for the emulator.

    http://wiki.forum.nokia.com/index.ph...ferent_machine

  4. #4
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: Implementing a server providing sockets, but where to start

    cool, they are in fact similar to what i managed to write ! well its been more than 2 years i have written socket server and hence was not too sure.

    do let know if you face any problems
    Amit Kankani
    Nokia Developer Champion

  5. #5
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    101

    Re: Implementing a server providing sockets, but where to start

    Hi,

    no problems so far, I just want to advert to an article on the wiki, which explains the whole socket stuff quite in detail. I'm only half way through yet, but so far it's very informative.

    http://wiki.forum.nokia.com/index.ph...he_sockets_API

  6. #6
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: Implementing a server providing sockets, but where to start

    looks really very informative ... nice search
    Amit Kankani
    Nokia Developer Champion

Similar Threads

  1. Server sockets
    By jhnwkmn in forum Open C/C++
    Replies: 1
    Last Post: 2007-04-12, 11:13
  2. How to bind UDP server sockets?
    By mimo099 in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2004-10-15, 19:31
  3. Can't start Nokia Activ Server Manager
    By Nokia_Archived in forum WAP Servers
    Replies: 2
    Last Post: 2002-05-24, 07:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×