I am attempting to write my first c++ program. It is a bot that will me used to connect to a Multi User Dungeon.

The premis is this

The application will open a server on a specified port on the local machine, and also connect to the MUD server. The application will act as a go between (bouncer) to sent commands from a separate mud client to the mud server.

The user will connect to the local server instead of directly to the mud.

The application will also pass the text from the mud (line for line) back to the client end.

in the end i will be adding the ability to parse input both ways and replace certain lines of text with others, or automatically respond to input from the mud automagicaly.

Im doing this dev c++ and all in winblows. Im using winsock.

So far I have been able to create the local server and connect to it from the mud client.

Next step is to connect the local server to the mud server.


Do i need 2 seperate threads to do this?


also any other help or examples of similar applications would be greately appreciated

Recommended Answers

All 7 Replies

> I am attempting to write my first c++ program.
Mmm'kay.

> It is a bot that will me used to connect to a Multi User Dungeon.
Not likely.

> Do i need 2 seperate threads to do this?
Are you just throwing terminology around to impress us?

IMO, you need to put this idea on hold for 6 month and set about learning C++ from the beginning.

Sure, you might get there yourself, but every other day you'll be in some kind of hole, and on a message board asking for help on the latest problem you're faced with.
It might eventually get written, but it won't have anything to do with your skill as a programmer.

> I am attempting to write my first c++ program.
Mmm'kay.

> It is a bot that will me used to connect to a Multi User Dungeon.
Not likely.

> Do i need 2 seperate threads to do this?
Are you just throwing terminology around to impress us?

IMO, you need to put this idea on hold for 6 month and set about learning C++ from the beginning.

Sure, you might get there yourself, but every other day you'll be in some kind of hole, and on a message board asking for help on the latest problem you're faced with.
It might eventually get written, but it won't have anything to do with your skill as a programmer.

We first of all, I said im writing MY first c++ program, that does not mean that haven't been playing around with other code for a while.

Secondly info about the mud can be found at lithmeria.com (still beta) and your sarcasm is unappreciated.

Thirdly im not throwing around terms here..

I already have one loop that handles data back and forth between the mud client and my server. i figured that i would have to have another loop that handles data back and forth from my server (which will also contain a client) and the MuD server. not sure exactly how important thread synchronization would be (would i need to use semaphore). I dont want to loose any data in either direction.

So im thinking i need 2 loops going at the same time with some way to talk back and forth between them (hence my semaphore question)


Thanks for the sarcastic introduction to the community Salem. Im sure you feel like a big man squashing people after their first post. Jerk

Here is the loop.
it works fine and just sends test data, and replies to any received data with the same thing

while(1)
	{ 

		bytesRecv = recv(m_socket, recvbuf, 512, 0);

		if (bytesRecv == SOCKET_ERROR)
		printf("Server: recv() error %ld.\n", WSAGetLastError());
		else
		{
			//receive 
            printf("Server: recv() is OK.\n");
			printf("Server: Received data is: \"%s\"\n", recvbuf);
			printf("Server: Bytes received: %ld.\n", bytesRecv);
			
			// send the same data back to the client (for testing)
			printf("Server: Sending same data back to client...\n");
	        bytesSent = send(m_socket, recvbuf, strlen(recvbuf), 0);\
	        if (bytesSent == SOCKET_ERROR)
	           printf("Server: send() error %ld.\n", WSAGetLastError());
	        else
	        {
		        printf("Server: send() is OK.\n");
		        printf("Server: Bytes Sent: %ld.\n", bytesSent);
	        }
			
		}
	}

We first of all, I said im writing MY first c++ program, that does not mean that haven't been playing around with other code for a while.

Secondly info about the mud can be found at lithmeria.com (still beta) and your sarcasm is unappreciated.

Thirdly im not throwing around terms here..

I already have one loop that handles data back and forth between the mud client and my server. i figured that i would have to have another loop that handles data back and forth from my server (which will also contain a client) and the MuD server. not sure exactly how important thread synchronization would be (would i need to use semaphore). I dont want to loose any data in either direction.

So im thinking i need 2 loops going at the same time with some way to talk back and forth between them (hence my semaphore question)


Thanks for the sarcastic introduction to the community Salem. Im sure you feel like a big man squashing people after their first post. Jerk

Well, first off I guess I should say Welcome to the forums!.... ok the second thing is, I know sarcasm wasn't really called for here but it would be easier if you posted your code with a lot of comments on where you need help/ are confused about.

Well there is not code yet for the client. im still trying to figure out exactly how to approach the situation. its basically like a bidirectional telnet bouncer. I know that sounds like something some script kiddiw wants to build, but im really trying to create a way to intercept commands and evaluate them. This is the easiest way i can think of because the client and the server already exist so i need a go between.

the client and the server already exist so i need a go between.

Then use select()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.