News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Listening to a port

Started by Danesh, January 03, 2005, 08:56:14 PM

Previous topic - Next topic

Robert Collins

Danesh,

OK, Those sample programs can be downloaded from the below link. Keep in mind, however, they are in C/C++ but I have found that it is not a real big problem to translate the C code into assembly code and the API calls are probably the same whether you use them in C or assembly. These are samples from just one of the chapters out of the book and they deal with creating a SMTP Mail Client program. Hope they will do you some good.

You might also go to Google.com and do a search on 'Winsock programs using assembly language'. I already did that and found many pages of good hits so you might find just what you are looking for.

Also, you might try www.programmersheaven.com. I am a member there and they have a hugh resource of sample programs in all languages.

Download sample SMTP at http://www.futureedge.com/smtp/MAIL_WINSOCK.ZIP

Statix Star

http://winprog.org/tutorial/

I was reading this for my C course and it teaches NETWORK programming handling WinHTTP.

wizzra

don't foget that when your listenning keep your listen() code in a thread, because you 'always' listen.
you don't want your app to be jammed in a endless loop while listenning.
:U

Danesh

Yes wizzra, you are right. Thanks for the tip. Thank you Robert, for the samples and help and thank you all for your valuable tips.


Regards,

Danesh


P1

Quote from: Danesh on January 05, 2005, 09:13:34 PM... This is not a private project.
Ok.  Why are you 'listening' to this port?  What is trigger event to signal this e-mail notification to the Admin?
i.e.  In one my projects, I used a technique simular to this to monitor Error Messages generated by client software to address the fact users assumed they caused the error and would not report them to me.

Regards,  P1  :8)

James Ladd

Hey,
Im the person that hutch is referring too.
Ill be working all day to get the first part of my tutorial up.
It probably wont contain the function your looking for as its a tutorial and im not at that stage yet.
I am, but I dont want to post code for later parts now.
If you need help them PM me or msn me.
Watch the forum for a notification of the web site being up the tutorial being available.

    Does anybody know how is it possible in MASM to listen to a port (e.g port 7777) and also, send packets from a remote host to a specific host on that port and be able to read and retrieve packets ?

The answer to the question is yes you can listen to a port. Using listen or WSA equivilant.
Sending and receiving packets is done with other functions but I prefer using select/WSAAsyncSelect or equivilant.
This removes the need to create a thread for each task and connection and makes the resulting application more scalable.
These topics will be covered in the tutorial.

regs striker.

sluggy

Quote from: Danesh on January 05, 2005, 09:13:34 PM
Well, this problem has been solved by great samples from Robert. Now, I am looking around for Mailing APIs. This is not a private project. As I have explained, it is a small program and will run on a server and will listen to a specified port. Under some conditions, it has to send a message to admin's email. Its all and it will install on a local LAN. 
If very limited email functionality is all that is required, why don't you look at using a Windows port of Blam? It is a small exe, you just give it the details on the command line and it puts together and sends the mail for you.

Danesh

Thanks Striker. I will keep watching the forum for your toturials and I will contact you if I had any problem.
P1, as I said, this is a small program which will install on a server and will listen for some special incoming  messages on a specified port. It should also be able to send a message to admin (on his email) to inform him that something need urgent attantion and I think this is exactly what you have done. Sending emails is now clear for me (thanks to Roberts great examples) and I am just working on it.
Sluggy, I don't know anything about Blam. I searched for it, but nothing found. What is it ? Can you explain more ?

Thanks,

Danesh


James Ladd

The winsock framework and tutorials (work in progress) is here: http://www.masmforum.com/simple/index.php?topic=431.0