Intercepting msgs sent from Net Send
Hi,
I'm currently building this Messanger application from VB which uses Net send to send msgs & to organize them... But I need a way to capture the Messages that r received, without havin them poped up on the scr... I'm currently using the FindWindow API to do this... but sometimes the Popup Dlg is visible for a few miliseconds and I need a more concrete method.... I know that the msgs arrive via the TCP port 139, & if there is a way to analyse those packets it would make my task easy.. So if anybody could help, it would be greatly appriciated... :bigyello:
1 Attachment(s)
Re: Intercepting msgs sent from Net Send
hmm I think that this is perhaps not the best way to go about a messenging system. Although it sorta seems convenient at first, because you probably can capture the message and who its from and time/date easily I guess? But I don't think it is a great idea to do it using net send.
First of all, the clients need to have the messenger service enabled in their windows to be able to receive net send messages at all. (I actually have mine off as they can be a nuisance sometimes), and second it would kinda be a pain in the ass with seeing the netsend window appear momentarily each time a message is received.
Basically you have to create a "multi-threaded" socket type thing. What this means is that you open up one socket (a port) and then all people connect to you through the same port, but assign each connection to a "thread" and each one has some form of id. Then when you are receiving, you can say if you are receiving from thread #1 and then have it stored somewhere that when thread #1 connected to you he sent his name as "steve", so send it to steve's conversation window. Or if it was from thread #4, send the message to anne's conversation window.
The same applies when sending - you want to reply in anne's conversation, so send the information through anne's "thread" so it goes to her machine.
This is all kinda complex to think about though, and I myself have never done multi-threading stuff in visual basic before -- only done it in Java. But seen as you started off using net send for transmitting information, I will assume (sorry if this is incorrect) that you don't have any previous knowledge with sockets.
To sort of understand how to use sockets first, I think it might be a good starting point to first try making a single-threaded messaging system. Around a year or so ago now, I was looking into the same kinda stuff -- not to create a messaging system, but rather use a messaging system as a starting to point to understand how to transmit data over the internet so I could later add online capabilities to my 2d space shooter i was making in direct draw :P You could play both on the one pc properly.. but eh anyway, I still have the thing I made last year. I'll attach it to this post and let you fiddle with it.
In this zip file you got a "listen" program, and a "send" program. Have a look in the code to try understand it a bit. Change the IP addresses/ports in there as you like. Once you got the ip address set, open "listen" first, then open "send". If you don't have two computers, you can enter the ip address as 127.0.0.1 and open them both on the one computer and they'll work. (make sure you enter the same port in both listen and send)
Note that to be able to use winsock in your own program, you have to add the "Microsoft Winsock Control 6.0" component to your project (right click on tool bar -> Components), and for that you need MSWINSCK.OCX. If you don't have it it should be easy to find on google.
Once you understand that single-threaded example I attached there (one connection only for the one socket), try looking on google for an example on using multi-threading. I had a look for a bit on google myself, but couldn't really find something that would suit you. If you manage to find something good, let me know ;P I'm interested in seeing it too (not for any specific purpose, just wanna see it done in VB).
Multi-threaded stuff can be a bit of a pain, but I think ultimately it might be what you want. Someone else with better knowledge on it may be able to suggest something better though. Sorry I can't provide solid advice. Good luck with it anyway.
Edit: As an extra note, you mentioned about port 139. You don't actually have to use that port for your program -- I'd probably even advise against it, to prevent conflicts with other net send messages. If you go up a few thousand ports you should be safe from conflicts.
Edit #2: I'm just new here too >.> Noticed that there is a code bank on this forum, and found this topic:
http://www.vbforums.com/showthread.p...hreadid=296315
Haven't tried it, but hope it helps.