14
DIY an AIM Step by Step Wenjin Hu

DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

  • View
    216

  • Download
    1

Embed Size (px)

Citation preview

Page 1: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

DIY an AIMStep by Step

Wenjin Hu

Page 2: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

Find Your Machine IP

• Type the command “ifconfig”– Find your machine’s ip 128.153.14x.xxx

Page 3: DIY an AIM Step 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()

Page 4: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

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()

Page 5: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

Server draft code ver2.0

• Edit the file “aim.cpp”while(1){ ……recv…... ……display the msg…}

Page 6: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

Client draft code ver2.0

• Edit the file “aim.cpp”while(1)

{ …get the msg from the user… ……send……

}

Page 7: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

Server draft code ver3.0

• Edit the file “aim.cpp”while(1){ ……recv…… ……send……}

Page 8: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

Client draft code ver3.0

• Edit the file “aim.cpp”while(1)

{ ……send……

…...recv……}

Page 9: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

Server draft code ver4.0

• Edit the file “aim.cpp”while(1){ cout<<“Partner: ”;

……recv…… cout<<chattext<<endl; cout<<“Me: ” cin>>chattext; ……send……}

Page 10: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

Client draft code ver4.0

• Edit the file “aim.cpp”while(1)

{ cout<<“Me: ”

cin>>chattext; ……send……

cout<<“Partner: ”; …...recv……

cout<<chattext<<endl;}

Page 11: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

Draft code ver5.0

• Common cstring function strcmp(str1, str2) will return false if str1 is equal to str2

while( strcmp(chattext, “exit”) ) {

...... }

Page 12: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

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…… }}

Page 13: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

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; }

}

Page 14: DIY an AIM Step by Step Wenjin Hu. Find Your Machine IP Type the command “ifconfig” – Find your machine’s ip 128.153.14x.xxx

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