Solved

Creating a telnet server with viscual c++ 5.0

Posted on 1998-07-15
7
542 Views
Last Modified: 2012-06-27
env: win95  compiler:msvc++ 5.0

What I would like to do is create a telnet server using mfc (if practical). I've been giving this some thought and decided that use of a sdi would be best. I've alreay layed out what I think the shell should look like, but I'm compeletly lost with the acutal code for the server. This server will serve as a mud server. I'd like for it to handle as many ppl as my system can handle. I'm not sure what other info one would need to answer this question.
recap:
1. a telnet server using msvc++ 5.0
2. created as a SDI
3. will serve as a MUD/Chat server (nonirc)
4. run on win32 systems
5. if any more info is needed please ask.

as a side note, i do know the differences between stream, raw, and data sockets. I've been doing some reading of my own :) Thanks for your time.
0
Comment
Question by:Noiroi
7 Comments
 
LVL 2

Expert Comment

by:igroove
ID: 1167903
Your best bet, since I have worked in developing software in this arena - is to use MFC's great CAsyncSocket (actually, your derived class from it) to handle the server "listening" socket, and create CAsyncSocket derived classes for each connection.  Since you're writing a SERVER, you should think about the end installed system OS, whether NT or 95 or 98...  the best performance and larget # of ppl you'd be able to handle would be on an NT system (either workstation or server).

Still, you should note that the server prolly would be _dedicated_ to use of your software, since it will be highly memory and process intensive in the end.

Read up on CAsyncSocket and threads.  Also, look at the source code for successful MUDs/MOOs like lambda moo (ftp.lambda.parc.xerox.com), and coolmud (don't know one specific ftp, but you can search for it at http://www.godlike.com./muds/mres/mftp.html - the MUD resource site).

Examine how they handle sockets - note that you'll have it sooo much easier in MFC!

Also, you'll need a copy of BISON/FLEX ported to Win32 in order to compile a "parser" if you're going to allow any sort of programming of objects in your system.  You can get one from www.cygnus.org or from my site www.cyberdrive.net/~igroove/ie (note you'll need IE4.0 to view my site).  My port of bison runs _without_ any additional DLLs or LIBs.

If it's a server, you won't need an omnipresent UI, though a system tray icon would be nice so a "local admin" can right click on it for a menu to do things to it like stop it, or see who's on, or checkpoint/dump it.

There's a lot to think about, and it's no small project if you've no server writing experience.

BEST OF LUCK!  and let us all know how it goes!
0
 

Author Comment

by:Noiroi
ID: 1167904
While the information given by Igroove was informative, it was still lacking in the information I need. I've read up on CAsyncSocket and have books (by Kate Gregory) on the topic, but not on Telnet. I've looked at the code for various muds(rom, circle, mud++) but I need a MFC example to follow. I don't know _how_ to use it properly.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1167905
Noiroi, you can get a *huge* amount of information, as well as great advice from:
  http://www.kanga.nu/~petidomo/lists/mud-dev

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Expert Comment

by:fritzinger
ID: 1167906
I've written a couple servers, and one of them happened to be a MUD. Here's my basic
development process for it:

The first thing to do would be to get your server working first of all.
Do a search on the web for "BSD SOCKET TUTORIAL". Winsock and Winsock2
follow the BSD Socket standard in certain respects. you may also try "VC++ SOCKET
TUTORIAL" so that you follow any MFC guidelines...

Once you have the server up, and listening, and it can accepts connections, then
decide on the "command set" you want to use for the MUD. Lot's of standard ones, and
if you're a MUD'er yourself, you are probably familiar with some already. like,
"kill <name>", "get <object>" and so on... basically, you want to read in their command,
parse the line, and determine which action to do based on their command.
0
 

Author Comment

by:Noiroi
ID: 1167907
Thank you for giving me more information to search on. I' going to reopen the question, because one can n'ver have too much information.
0
 
LVL 1

Accepted Solution

by:
bequette earned 70 total points
ID: 1167908
Basically what a telenet server does is this:
One thread ussually sits in an endless loop listening to a "Published port"  So for the first part of your design you need to choose a port number as your MUD connection port.  Create a main thread that listens on this port for connection requests.  When you get a request for a connection,  it is ussually a good idea to open another socket and have the main thread spin off a child thread to handle the regular data between the server and the clients.  The advantages of this are the fact that it becomes easy to dynamically allocate space for other users connecting and to manage them all.  It also lets you use the exact same code for all user data I/O.  The other advantage is your server dosn't block when it tries to accept a connection, and doesn't get hung by processing data through the socket since that is the responsibility of the child thread.  So for overview of the server's connection accepting scheme you have this:

Main thread opens a socket on a predetermined port
Main thread endlessly loops waiting for a connection request on the published port
When a connection is requested, open a new socket/port with a child thread to handle the data(this frees the original port, and puts main thread back in the original loop)


Now for your child thread.  What you need to do is define a standard set of commands.  The simplest idea involved in this is to use an integer.  Like an FTP server, for instance, you could  say a 1 is dir, a 2 is put, a 3 is get, a 4 is delete and so on.  Then you pass data through the sockets like you would write to a file.  You write to the socket as if it were a file handle, and you read from the socket as if it were a file handle.  

Now the tricky part comes in.  How do you know when there is data on the socket to be read, or if the socket is ready to be written too?  This will greatly depend on how you implement you sockets.  If you use CAsyncSocket, a lot of the above is taken care of for you.  If you want to use standard BSD sockets you need to use the standard iotcl(), or the Windows sockets versions of it(Win32, MFC, and so on)  Basically you will pass this function a map(implemented differantly in Winsock than in unix sockets) of the sockets you are worried about and the type of events you are worried about and the function will return telling you is there is any data to be read.  The specifics of this function are in the help depending on how you implement sockets.  I recommend using MFC if your not real familiar with network comms as the bulk of the work is done for you.  I recommend highly if you are a little familiar with network comms, Win32s, and Overlapped I/O to check out COverlappedSocket in "Win32 Network Programming" by Ralph Davis (Addison-Wesley Publishing http://www.aw.com/devpress/

Now, some details like how you intend to close the sessions, how you want the server to manage security and things like that, you still need decide.  That's kind of an overview of the way a standard servers works, i.e. listen to a port and spawn a worker thread.  Hope that helps, if it's not what you need please reject and let me know what your still missing.
0
 

Author Comment

by:Noiroi
ID: 1167909
Thank you for your response. Also, thank everyone for their respones, I appreciate the guidence provided. If anyone knows of some help reading material, please suggest it. Thank you again. Noiroi
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now