Joke Collection Website - Cold jokes - Flying pigeon book software Flying pigeon book software can chat on LAN. How is it achieved? If there is a little? Implementation code.

Flying pigeon book software Flying pigeon book software can chat on LAN. How is it achieved? If there is a little? Implementation code.

LAN Chat Software Flying Pigeon Spreading Books is a popular LAN instant messaging software at present. Because of its long history, there are many users. Because the realization principle of FreeEIM is similar to that of flying pigeon passing books, I hope users will be more handy when using it after understanding its principle. When the program starts, the user profile is read first, usually in "*". Ini format, and then use Winsock's broadcast message to send a packet to the whole LAN. At this time, if other computers have run the flying pigeon book, he will read the information of the package after receiving it. Of course, this package contains the user's IP, user name, gender and so on. In this way, there is one more user in the user list. His user checking method is as simple as that. As for the implementation across network segments, just modify the broadcast address. If speed is not considered, broadcast messages can be sent to the whole Internet. The functions of message sending and file transfer are relatively simple. If you can program the network and give you the IP address of the other party, these functions can be realized simply. Voice, video, etc. , just write some voice and video capture codes. If you pass a book, it's just like passing a file. The following is the implementation code of segment broadcast message://Send broadcast login message.

void EM _ UserLogin::SendLogin _ BC(LPEM _ DATA msg)

{

SOCKET m _ socket

m_socket = socket(AF_INET,SOCK_DGRAM,IP proto _ IP);

If (invalid socket == m socket)

{

MessageBox(0, "Socket failed." ,NULL,MB _ OK);

}

SOCKADDR _ IN sinsin . sin _ addr . s _ addr = htonl(in addr _ BROADCAST);

sin.sin _ family = AF _ INET

sin . sin _ PORT = htons(BROADCAST _ SEND _ PORT); BOOL bOpt = TRUE

if(SOCKET _ ERROR = = setsockopt(m _ SOCKET,SOL_SOCKET,SO_BROADCAST,(char *)& amp; bOpt,sizeof(bOpt)))

{

//An error occurred

* MessageBox(0, "BC setsockopt error." ,0,0);

Return;

}

char * tmpBuf = msg-& gt; get buffer();

if(SOCKET _ ERROR = = send to(m _ SOCKET,tmpBuf,msg-& gt; GetLength(),0,(PSOCKADDR)& amp; sin,sizeof(sin)))

{

//An error occurred

* MessageBox(0, "BC sent to error." ,0,0);

Return;

} close socket(m _ socket);

} We should keep up with QQ, MSN, ICQ, AIM and other large-scale instant messaging. Compared with them, XEIM is just a poor student in the class. If we want to catch up with these excellent students, only by making greater efforts can we catch up with or even surpass them. However, if you do nothing, it will become a joke. The principle of flying pigeon delivering books: (1) The most important thing is the establishment of LAN user list; When the flying pigeon starts, it uses UDP protocol to send broadcast packets to the broadcast address 255.255.255.255, and the default port is 2425. The broadcast package contains user name, workgroup, host name, IP and other information;

After receiving this broadcast packet through port 2425, the user who has started flying pigeon will add the user name, workgroup and other information to his user list, and send the personal information of the local user to the other IP; So that both parties can establish a user list; (2) The broadcast packet sent when refreshing the user list is similar to that at startup, but the returned identification information is slightly different; Can be a small tool to monitor the memory flow of port 2425, which can intercept messages when refreshing and chatting. (3) UDP protocol is also used when transmitting chat information; Because UDP is a connectionless protocol, the transmission speed is fast, but there is no confirmation mechanism, which is an unreliable protocol. You need to define the sign of returning information to judge whether the other party has received the information. (4) When the user is offline, send an offline broadcast packet to 255.255.255.255, and the user who receives this broadcast packet will delete the other party's user list information according to the IP address in the packet (which may also include various judgment marks or hardware marks, such as network card address, etc.). );

(5) WAN can't directly use broadcast mode, but manually add "off-network broadcast list" to establish mutual relationship; (6) Flying pigeons use TCP protocol to transmit files, port 2425; Other information: 1. Flying pigeon uses C++ language, and the development tool: Visual C++4. 1, 6.0, or higher version; 2. Flying pigeons are open source. Download the source code from the websites of the author (Zhang Kai Shiraishi from Hiroshima, Japan) and the Sinicizer (A Zhi). The source code is marked in Japanese; You can modify the compilation with VC++; 3. Flying pigeon biography is a software from Japan, and the Japanese version is its first version; There are also Chinese, English, Korean, Portuguese and other languages; 4. Encryption algorithms used by flying pigeons: RSA, Blowfish, RC; 5. Flying pigeons can send messages through the command line. The command format is as follows: ipmsg [port]/msg [/log] [/seal]; < message > you can change the default port by using the IPMsg [Port] command, and start multiple instances at the same time, but only users who use the same port can receive interactive information after modification; 6. The non-installed version of Flying Pigeon is not a purely portable application. Deleting directly will leave junk key values in the registry; * Flying Pigeon saves all setting information in the following location in the registry: \ \ HKEY _ Current _ User \ Software \ hstools \ User password is stored in an irreversible encryption way. * If you forget the password, you can delete this key value in the registry and clear the password * \ \ HKEY _ Current _ User \ Software \ Hstools \ ipmseng \ passwordstr 7. When the number of files transmitted by flying pigeons reaches several thousand at a time, it is possible to lose files, which is suspected to be a bug of flying pigeons, but there is no problem in transmitting large files; 8. The most stable official version of flying pigeon is V2.06;; At present, version v2.50 alpha6 is being tested and has not been officially released; Others, such as 2.7 1, the 2007 green version is a modified version, not a genuine one;