Results 1 to 10 of 10

Thread: more network connections simultaneously

  1. #1
    Join Date
    May 2006
    Posts
    14
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default more network connections simultaneously

    hey guys,
    i'd like a following thing to do.
    imagine server <-> client application. they communicate through QSocket. I'm sure you all know example from http://www.codeskipper.com/article/3/

    now i'd like to do following:
    - open one connection for like a chat window ( it is already in the example)
    - temporary open hiden connection for sending some files, but on the different socket/port ???

    I don't really know how should i do it. i think i didn't really understood principle of connecting through sockets

    could anybody sketch me please how could it work?

    zhank you guys.
    QT3winFREE....doin' just 4 fun

  2. #2
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: more network connections simultaneously

    What do you mean by saying "hidden connection"? Hidden from whom?

  3. #3
    Join Date
    May 2006
    Posts
    14
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: more network connections simultaneously

    i mean i want to send commands from my client to server on the background. if client push the button for some status message for example, it should send "status command" to server and client gets some status back from server application. but this should be done sepparately from "chat connection". i need just have some additional connection paralel to chat connection.
    QT3winFREE....doin' just 4 fun

  4. #4
    Join Date
    May 2006
    Posts
    14
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: more network connections simultaneously

    i do not really know how to describe it

    may be different. i have 2 connections in one process for example between server and client application. qt gives these connections 2 different ports. Am I correct?

    I connect one signal to send data through port #1 and other signal to send data through port #2. How can server application decide from which signal i send the data? because i would like to send processed data from server back using the same port as sent

    i hope U understand
    QT3winFREE....doin' just 4 fun

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: more network connections simultaneously

    But what exactly is the problem? What keeps you from simply making a new socket object and opening a connection there just like you did with the first one?

  6. #6
    Join Date
    May 2006
    Posts
    14
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: more network connections simultaneously

    i can add a new socket and open it. that is no problem. means i will have:

    socket #1
    socket #2

    then i send some text through socket #2, server application will process this text and send back modified text. so now, how can server recognize that it should send data back through socket #2, not using socket #1?

    i want simply have two separate channels for communication between server and client
    QT3winFREE....doin' just 4 fun

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: more network connections simultaneously

    Quote Originally Posted by cmeliak
    how can server recognize that it should send data back through socket
    The same way as the client, because it will also have two sockets.

  8. #8
    Join Date
    May 2006
    Posts
    14
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: more network connections simultaneously

    ok. if i understud it well, i should create 2 sockets on the client and two sockets on the server. so, but how to force client to connect to certain socket? actualy server creates socket for each connection. i am really confused guys. do you have some picture for me?
    QT3winFREE....doin' just 4 fun

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: more network connections simultaneously

    Quote Originally Posted by cmeliak
    how to force client to connect to certain socket?
    You can't. Client connects to a given port and it even doesn't know what program listens there.

    You could use different ports (like FTP does), but IMO it isn't necessary. Just add another command to your protocol that will allow clients to choose connection type. For example "CHAT MODE" would switch the connection into chat connection, while "CONTROL MODE" --- into connection that controls the session.

    You will also need some kind of authentication mechanism, so that can tell which connection belongs to which client (note that user might start multiple instances of a client program on his computer).

    But do you really need two connections?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: more network connections simultaneously

    Quote Originally Posted by jacek
    You could use different ports (like FTP does), but IMO it isn't necessary. Just add another command to your protocol that will allow clients to choose connection type. For example "CHAT MODE" would switch the connection into chat connection, while "CONTROL MODE" --- into connection that controls the session.
    Or provide control sequences made of unused characters (and escape them during normal transmission) so that you don't have to handle different "modes".

    To be honest this should be simply realised as urgent data (TCP) but I doubt Qt allows one to send/receive them.

    Edit: Another way could be to provide "commands" between the client and the server and treat chat transmission as another command in network traffic.
    Last edited by wysota; 8th June 2006 at 01:20.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.