Dyroxide (21st November 2008)
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.
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 10:17 AM.
Dyroxide (21st November 2008)
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
Dyroxide (21st November 2008)
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

LAN is local network?
There are currently 1 users browsing this thread. (0 members and 1 guests)