View
216
Download
1
Embed Size (px)
Citation preview
DIY an AIMStep by Step
Wenjin Hu
Find Your Machine IP
• Type the command “ifconfig”– Find your machine’s ip 128.153.14x.xxx
Server draft code ver1.0
• Edit the file “aim.cpp”– #include “server.h”– Server Link( 5001)– Link.connect()– Link.recv_string( arrayname, size)– Display the msg on the terminal– Link. closesocket()
Client draft code ver1.0
• Edit the file “aim.cpp”– #include “client.h”– Client myClient( 5001, “128.153.144.xxx”)– Get the message from the user/terminal– Link.send_string( arrayname)– Link. closesocket()
Server draft code ver2.0
• Edit the file “aim.cpp”while(1){ ……recv…... ……display the msg…}
Client draft code ver2.0
• Edit the file “aim.cpp”while(1)
{ …get the msg from the user… ……send……
}
Server draft code ver3.0
• Edit the file “aim.cpp”while(1){ ……recv…… ……send……}
Client draft code ver3.0
• Edit the file “aim.cpp”while(1)
{ ……send……
…...recv……}
Server draft code ver4.0
• Edit the file “aim.cpp”while(1){ cout<<“Partner: ”;
……recv…… cout<<chattext<<endl; cout<<“Me: ” cin>>chattext; ……send……}
Client draft code ver4.0
• Edit the file “aim.cpp”while(1)
{ cout<<“Me: ”
cin>>chattext; ……send……
cout<<“Partner: ”; …...recv……
cout<<chattext<<endl;}
Draft code ver5.0
• Common cstring function strcmp(str1, str2) will return false if str1 is equal to str2
while( strcmp(chattext, “exit”) ) {
...... }
Server draft code ver6.0• Edit the file “aim.cpp”
while(strcmp(chattext, “exit”) ){
……recv…… cout<<“Partner: ”; cout<<chattext<<endl; if(strcmp(chattext, “exit”) ) { cout<<“Me: ” cin>>chattext; ……send…… }}
Client draft code ver6.0• Edit the file “aim.cpp”
while(strcmp(chattext, “exit”) ) {
cout<<“Me: ” cin>>chattext;
……send…… if(strcmp(chattext, “exit”) ) { …...recv……
cout<<“Partner: ”; cout<<chattext<<endl; }
}
More versions?
• 7.0 – Display partner’s nickname
• 8.0– Let partner send you his/her nickname
• 9.0– use class string instead of cstring (more safe)
• 10.0– Let the string take space or tab
• ……– Whatever you think it is better