Results 1 to 2 of 2
  1. #1
    gilme is offline Member
    Join Date
    Jun 2010
    Rep Power

    Question design & generics for socket server


    I'm dealing a small program that has a SocketServer.
    I have a specific simple protocol that I'm implementing by myself.

    For the server I'm openeing a thread for every new session = socket
    (for a user connecting to the server).

    The problem is with the protocol design:
    I want to have an abstract class for "Message" - a protocol message between the server and the client.

    I tryed to create inside a "Session" class (which identifies each connection = independant socket) an abstract class for Message, so each session can instantiate new messages for every request (=message).

    The problem - something with the generics doesn't seem to work.
    These are the relevant headers:
    public class Session <M extends Message> extends Thread {
    public abstract class Message {
    public abstract String treatMessage(InetAddress ip, int port);
    public class Introduce extends Message {


    inside "Introduce" class I get error messages from eclipse:
    "no enclosing instance of type Session<M> is available due to some intermediate constructor invocation."
    "Session.Message is a raw type. References to generic type Session<M>. Message should be parametrized."

    The design is in this way because all sessions share the same database, and this is the design I found
    for this situation (inner class). If any new good idea for design I'd love to hear..


  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Waterford, Ireland
    Rep Power

Similar Threads

  1. Server Socket
    By Moncleared in forum New To Java
    Replies: 1
    Last Post: 09-05-2009, 07:08 AM
  2. Server socket - send image to client
    By Hinty in forum Networking
    Replies: 2
    Last Post: 03-14-2009, 08:39 AM
  3. Replies: 1
    Last Post: 02-10-2009, 10:16 AM
  4. (Server)Socket application deploying
    By mdinant in forum Networking
    Replies: 0
    Last Post: 04-09-2008, 06:10 PM

Posting Permissions

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