Home > Software engineering > MFC to write a IP white list program, could you tell me where to start!
MFC to write a IP white list program, could you tell me where to start!
Time:09-24
I am a novice, wrote a client and server, to accept the data, Want to use the server to send after get IP as white list can access port, There now, a great god, please help
The client sends code:
cstrings strIP;
Cstrings strSource; Cstrings Address="http://city.ip138.com/ip2city.asp"; CInternetSession session (" Microsoft Internet Browser ", 0); CHttpFile * myHttpFile=NULL; MyHttpFile=(CHttpFile *) session. OpenURL (Address); While (myHttpFile - & gt; ReadString (strSource)) { Int the begin=0; The begin=strSource. Find (' [', 0); If (the begin!=1) { Int the end=strSource. Find ('] '); StrIP=strSource. Mid (begin + 1, end - the begin - 1);
Cstrings szSendText szInfo; M_ServerIP. GetWindowText (szSendText); if (! SzSendText. IsEmpty ()) { SzInfo. The Format (user IP white list, "" % s", strIP); M_SockClient. Send (szInfo GetBuffer (szInfo GetLength ()), szInfo. GetLength ()); } } }
The client code, have access to the user IP, to join white list!
And the service side, I don't know how to write, Receive the data, how to add the IP protection within the server program! For example: Server server running, the server port 80 for sealing state, unless the user run the client after obtaining IP, IP will be sent to the server, Can access port 80 Is not running the client users can't access, can you tell me the client needs to write!
CodePudding user response:
This thinking is a little trouble Should not be closed port Port should have been effective, found that the client to connect the IP check each other, if not in the white list Closes the connection