Results 1 to 9 of 9

Thread: multiple sockets....like an array i guess...

  1. #1

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196

    multiple sockets....like an array i guess...

    im logging in a few names into a server so i want to setup , i guess i would be called a socket array....they sockets class im using is not a control....how bout some code to make an array...im going to have my names in a listview if that helps any....plus each name is gonna be sending different commands....so i would like u to show me how to identify and use each socket in the array bc i have never used arrays in any of my apps ....thx in advance

    AcE

  2. #2

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196
    maybe thats a bit confusing.....heres another question....i could make a loop threw all my items saying something like this.....but how could i do it....

    dim lv_ids.items(itemnumber).text as new socketclient

    AcE

  3. #3
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    u cant give names at runtime like that..the best thing to do is just create a collection (arraylist or hashtable) and fill it up with all the sockets
    \m/\m/

  4. #4
    Addicted Member Nigh™a®e's Avatar
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    175
    Hi,

    I done a simmular thing in one of my projects.

    What i did is created the ClientSocket class thats running at the server and a listener at server.

    When a connection is made, a new instance of the ClientSocket is made and the new connection is linked to it.
    Some handlers are added to control between the listener and client classes.

    The client classes can be put into a hashtable or dictonary collection using the loginname as key (needs unique login names, and only allows a user to log in once).

    If you want to send some data to all connected users, just use the enumerator to access all clients connected.
    To send to 1 specified user, get the client class from the collection.

    By using handlers and events again, a class can be removed from the collection when connection is closed.

  5. #5
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    could i get those classes nightmare?
    \m/\m/

  6. #6

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196
    guess my situation is sortof like that.....i got like 30 connections to a specific server.....then maybe be connected to multiple servers....could some1 gimmie a brief example of using a collection of arrays....maybe how to assemble the collection and then how to do the socketclient.senddata for each item in the collection....and maybe how to get the data recieved....im having a hard time telling how to use arrays....i wuz doing vb6 befor .net but i never got around to arrays so i dont really understand them bc of my lack of experence......any help is better than none @ all...thx for ur help so far

    AcE

  7. #7

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196
    nm i found an example....heres the url if any1 wants it....its just wut i needed.....http://planet-source-code.com/vb/scr...52003104498834

    thanks guyz

    AcE

  8. #8
    Addicted Member Nigh™a®e's Avatar
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    175
    Originally posted by PT Exorcist
    could i get those classes nightmare?
    Sure, i will look for the cd and put it online.
    Its actuly an messenger program with server / client application.

    you can connect and login to the server, but i never finished the rest of the commands and scripts.

    But the serversided client classes are usefull.
    I will also put an example serverclass with it that handles the incomming connections, closed connection and message responses.

    If you are looking for examples, you can also find 1 in .NET itself, multisockets or something like thats, but it isnt so usefull, cause it only makes a connection and direcly closes it again.

    Greets Nightmare

    ---
    ps: if somebody like to help to finish the messenger, it would be cool, its a simple messenger that doesnt has all the special features like icq, msn, .... so less command, less bugs and safer progam. I made it more for private use, so i want to put the application on my site so everybody can dowload for free, maybe even make the source available for in case people want to add theyre own functionality

  9. #9
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah ok nightmare when u find it then post it here plz
    \m/\m/

Posting Permissions

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



Click Here to Expand Forum to Full Width