+ Post New Thread
Results 1 to 5 of 5
Coding Thread, Visual Basic 2008 LAN Chat Room in Coding and Web Development; I am currently a student at Sentinel Career Center's CCNT program (Computer Communications Network Technician). I was hoping to get ...
  1. #1

    Join Date
    Nov 2008
    Thank Post
    Thanked 0 Times in 0 Posts
    Rep Power

    Visual Basic 2008 LAN Chat Room

    I am currently a student at Sentinel Career Center's CCNT program (Computer Communications Network Technician). I was hoping to get some help making a simple chat room using visual basic from scratch. It has previously been suggested to me that I should use c4f p2p toolkit to do this. What fun is that though? I want to make it without outside programs but i havn't a clue how to make the chat room run in my classes LAN. No, I am not using this for evil, netsend in our class is not disabled (this was from another post I saw earlier I just wanted to clarify this). I want a simple program to display usernames and messages next to them that say 3 people viewing my program could read.

    could you please give me some general direction as to what things i will need to look up to make this work.

    I'm not looking for someone to write the code for me just to tell me what I would need to research and put the code together.

    here is a simple layout of the program when it is run (what I hope it will be like)
    [chat room - [] x ]
    |user 1: hello |
    |user 2: how are you user 1 and user 3? |
    |user 3: i'm ok its a good thing they helped you on |
    | edugeek.net forums |
    |user 1: yea. |
    | |
    | |
    | |
    | [Send] |

    Something to that effect.. i hope it doesnt make all that spaced out and ruined that took me a decent amount of time to draw out :\

    anyways I would appreciate any direction that you can give me, and please i dont want any downloads i want to code this myself i just need general direction on what i would need to do to make this work.

  2. #2
    Friez's Avatar
    Join Date
    Dec 2006
    Thank Post
    Thanked 22 Times in 21 Posts
    Rep Power
    I'm not that hot on VB, but I code C/C++/C#/Perl/PHP/ASM
    I'll go over the design/theory of the thing (applies to whatever language you may be using), but I won't list source codes (else I may as well be handing over a copy of mIRC).

    Firstly, you need to read up on SOCKETS. If it's a windows app, winsock should be right up your street. Sockets are what allow you to do the raw networking stuff.

    There are two types of sockets: Blocking and Non-Blocking. A blocking socket will sit and wait for data to recv() or send(), whereas non-blocking sockets use select() in order to see if theres data to be written/read and does so asynchronously.

    There's tutorials on the web for this sort of thing, go google.

    You need to decide what sort of sockets to use in your program.

    Additionally, You will want to consider how your app is going to function. Is it peer-to-peer, or is it client-server model? The easiest model to code for conceptually is client-server. At any rate, your network code will be shaped around your design decisions at this stage.

    If you choose the client-server model you will need to consider making two applications (obviously). The server will need to handle multiple connections (often simultaneously).

    Thus, a blocking socket would be insufficient. (For example: Server waits infinitely for a line of text from client A, client B sends some text, but server is still waiting for client A, so nobody gets an update until client A talks).

    To do this you need to do one of the following:
    Use Select() and non-blocking sockets.
    Use Multithreading (pthreads or microsoft threads) to spawn a 'worker thread' to handle that client exclusively (using a blocking socket), the thread provides "simultaneous" processing power as to prevent the other users from being blocked. Threads of course require you to be careful with design to ensure you don't end up causing deadlock or causing issues (resources are shared in the program, so writing to a variable not intended exclusively for a thread will change for ALL other threads, causing inconsistency if it's not policed).

    Now that you know what sort of tech you're looking at, you now need to design your app. Yes, design. At the least, make a finite state machine for your program(s) designing what states your program can get into.

    You will also need to design your networking protocol. It's quite likely you'll use TCP/IP for this (UDP is unreliable, but faster/less overhead, chances are you'll want the reliability of TCP for an app like this since it is quite lightweight, unlike a game).

    Ontop of that layer of the OSI model (go google) you'll be writing your own protocol. This is to handle the message interaction between client-server and server-client. E.g.

    Client sends message like so:
    [0][USERNAME] - the first byte (0) indicates user is logging in/renaming to subsequent bytes in [USERNAME]
    [1][MESSAGE] - the first byte (1) indicates user is sending a message to everyone in the chat
    [2][USERNAME][1][MESSAGE] - the first byte (2) indicates the user is sending a whisper to a user. The username is specified up to the binary value of 0x1, and then the message is listed up to the end of transmission.

    As you can see, you need to put a lot of thought and design into this, plus have a decent understanding of network programming.

    Topics for you to research:

    • Finite State Machines
    • OSI Model
    • Sockets / Winsock
    • Multi Threading
    • TCP/UDP

    Good luck!
    Last edited by Friez; 21st November 2008 at 09:17 AM.

  3. Thanks to Friez from:

    Dyroxide (21st November 2008)

  4. #3
    Scruff's Avatar
    Join Date
    May 2007
    Thank Post
    Thanked 3 Times in 3 Posts
    Rep Power
    I would suggest the first thing you need to look into is the System.Net.Sockets namespace for communicating over TCP

    Here is a link to the msdn article to get you going - MSDN

  5. Thanks to Scruff from:

    Dyroxide (21st November 2008)

  6. #4

    Join Date
    Jan 2009
    Thank Post
    Thanked 0 Times in 0 Posts
    Rep Power

    ok im making basically the same thing

    im making basically the same thing i have everything working if u need help ill help u with what i can mine works on a local network now trying to make it go lan

  7. #5

    Join Date
    Feb 2007
    Thank Post
    Thanked 794 Times in 714 Posts
    Rep Power
    LAN is local network?

+ Post New Thread

Similar Threads

  1. Visual Basic - LAN Message Program - Help
    By JavaNocKziK in forum Coding
    Replies: 22
    Last Post: 24th September 2008, 01:32 PM
  2. Visual Basic 6 and administrative priveleges
    By googlemad in forum Windows
    Replies: 0
    Last Post: 5th February 2008, 11:06 AM
  3. Video Chat / web chat over LAN
    By johnkay21 in forum Windows
    Replies: 10
    Last Post: 5th October 2007, 07:52 AM
  4. Visual Basic 6
    By Samson in forum Windows
    Replies: 4
    Last Post: 30th August 2007, 12:41 PM
  5. Visual basic 6
    By Halfmad in forum Windows
    Replies: 9
    Last Post: 11th June 2007, 02:57 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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