SlideShare a Scribd company logo
1 of 33
Download to read offline
12147334 임성국
13109306 강태우
13109323 김희라
14125328 설유미
14109364 임정후
16101340 강지훈
2017-2 Unix Programming
Contents
1.
Introduction
2.
Program Structure
: server-side
: client-side
3.
Demonstration
1.
Introduction
1. Introduction
GameChatting
main feature
Number Baseball ?bulls and cows
Strike
Ball
OUT
When the numbers and seats coincide,
When the numbers are right and the seats are incorrect,
When there's no numbers and no seats
Game Roles
Answer :1543
Your number :4598
Number Baseball ?bulls and cows
1S1B
Strike
Ball
OUT
When the numbers and seats coincide,
When the numbers are right and the seats are incorrect,
When there's no numbers and no seats
Game Roles
Answer :1543
Your number :4598 1S1B
2.
Program Structure
2. Program Structure
Flow chart
START main
Leader
board
help
exit
enter game finishchatting
Everyone
is ready
Recode result
If someone
wins
2. Program Structure
임성국
강태우
김희라
설유미
임정후
강지훈
Server, Client
Leader Board
UI, Server
Leader Board
Server, Client
UI, Client
Role
clientConnection clientConnectionclientConnection
chatting
baseball
connectconnect
createSocket
main
Server structure
2. Program Structure
Server
int main{
…
createSocket();
}
createSocket() {
// initialize server
// error handling
clientSocket = accept(serverSocket, …, …);
//create thread >>> clientConnection()
}
Server
int main{
…
createSocket();
}
ClientConnection() {
// chatting
// gameReadyCheck
// baseballgame
}
Server
void sendMessage() {
if(flag == 1)
//send code to client
if(flag() == 0)
//send chattong to client
}
Server
void *clientConnection() {
//game algorithm
...
writeResult();
}
Server
void writeResult() {
//file make and write
..set permission
}
if(menu == 1){
…
gameRun();
}
Client : Menu
gameRun() {
// Draw gamescreen
// clearScreen function is system(“clear”);
clearScreen();
drawFunction(“textImage/gameScreen.txt”);
}
Client :
drawFunction() {
int c;
FILE *filePointer;
filePointer = fopen(filepath, “r”);
if(filePointer) {
while((c = getc(filePointer)) != EOF)
putchar(c);
fclose(filePointer);
}
Menu – drawFunction()
gameRun() {
struct passwd *pw;
//set client name
uid = getuid();
pw = getpwuid(uid);
}
if(menu == 1){
…
gameRun();
}
Client : Chatting
gameRun() {
pthread_t receiveThread;
//make receive thread
pthread_create(&receiveThread, NULL, receiveMessage,
(void*)clientSocket);
}
if(menu == 1){
…
gameRun();
}
Client : Chatting
Client : Thread – receiveMessage()
receiveMessage() {
// receive message from server.
read(Client, ..,);
// move to chatting position and print
gotoxy(x,y);
printf(“%s”, message);
}
gameRun() {
if(key == Enter)
// If input Enter, client send message to server.
write(client, message, BUFSIZE);
if(myReady() == true)
// Draw R in screen.
drawFunction("textImage/gameReadyScreen.txt“);
}
if(menu == 1){
…
gameRun();
}
Client : Chatting
gameRun() {
if(getEveroneIsReady() == true) {
// currentMode 1 is chatting mode
// currentMode 2 is game mode
setCurrentMode(2);
...
}
if(menu == 1){
…
gameRun();
}
Client : Game
gameRun() {
if(isGameIsEnd() == true) {
// Break while and back to menu.
break;
}
...
}
if(menu == 1){
…
gameRun();
}
Client : Game
displayLeaderboard() {
int key;
void (*hand)(int);
//we can exit program with clearScreen.
hand = signal(SIGINT, exitFunction);
if(hand == SIG_ERR) {
perror(“signal1=L);
exit(1);
}
LB_display();
}
Client : Menu
if(menu == 2){
…
displayLeaderboard();
}
displayHelp() {
int key;
void (*hand)(int);
//we can exit program with clearScreen.
hand = signal(SIGINT, exitFunction);
if(hand == SIG_ERR) {
perror(“signal1=L);
exit(1);
}
drawFunction(…);
}
Client : Menu
if(menu == 3){
…
displayHelp();
}
Leader board :
4, 20, 12/31, player 1, 4, 23, 72, p1
Number of word, count, date, player name
result.txt
Typedef struct {
char * item[4];
int count;
}form;
Open function
Read function
Strtok function
Leader board : Parsing Function
Leader Board
-
Casting
intChar *
-
Number of matching
-
sort
Leader Board
File I/O
Parsing
&
STDOUT
Client
Leader Board
Encapsulation & Multithread
pthread_create()
pthread_join()
// wait until thread ends
Leader Board
File I/O
Parsing
&
STDOUT
Client
thread thread thread
Leader Board
Signal Handle
act.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &act, NULL);
// Ignore SIGPIPE (process excution
4.
Demonstration

More Related Content

Similar to Unix programming ver_realfinal

Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfmanjan6
 
ma project
ma projectma project
ma projectAisu
 
Forest assassin 2 d platformer game
Forest assassin 2 d platformer gameForest assassin 2 d platformer game
Forest assassin 2 d platformer gameAnshuman Pattnaik
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programingKrishna Agarwal
 
IRJET- Game Development Project – Sparta
IRJET-  	  Game Development Project – SpartaIRJET-  	  Game Development Project – Sparta
IRJET- Game Development Project – SpartaIRJET Journal
 

Similar to Unix programming ver_realfinal (8)

Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
 
ma project
ma projectma project
ma project
 
Forest assassin 2 d platformer game
Forest assassin 2 d platformer gameForest assassin 2 d platformer game
Forest assassin 2 d platformer game
 
Md2010 jl-wp7-sl-game-dev
Md2010 jl-wp7-sl-game-devMd2010 jl-wp7-sl-game-dev
Md2010 jl-wp7-sl-game-dev
 
L10 Using Frameworks
L10 Using FrameworksL10 Using Frameworks
L10 Using Frameworks
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
 
Street runner final
Street runner finalStreet runner final
Street runner final
 
IRJET- Game Development Project – Sparta
IRJET-  	  Game Development Project – SpartaIRJET-  	  Game Development Project – Sparta
IRJET- Game Development Project – Sparta
 

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Unix programming ver_realfinal