distinct address for server and client
This commit is contained in:
父節點
1d5ac76dfd
當前提交
17cc084b86
共有 1 個文件被更改,包括 12 次插入 和 3 次删除
|
@ -19,7 +19,8 @@ données du réseau */
|
|||
/* pour la gestion des erreurs */
|
||||
#include <errno.h>
|
||||
|
||||
#define DEFAULTPORT 9000
|
||||
#define DEFAULTSERVERPORT 9000
|
||||
#define DEFAULTCLIENTPORT 8999
|
||||
#define MSG_LENGTH 10
|
||||
#define NB_CLIENTS 1
|
||||
#define TCP_BUFFER_LEN 2000
|
||||
|
@ -189,7 +190,11 @@ int main (int argc, char **argv)
|
|||
// remplissage de l'addresse locale
|
||||
memset(&addr_local, 0, sizeof(addr_local));
|
||||
addr_local.sin_family = AF_INET;
|
||||
addr_local.sin_port = DEFAULTPORT;
|
||||
if (source) {
|
||||
addr_local.sin_port = DEFAULTCLIENTPORT;
|
||||
} else {
|
||||
addr_local.sin_port = DEFAULTSERVERPORT;
|
||||
}
|
||||
addr_local.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
printf("address built\n");
|
||||
|
@ -204,7 +209,11 @@ int main (int argc, char **argv)
|
|||
|
||||
memset(&addr_distant, 0, sizeof(addr_local));
|
||||
addr_distant.sin_family = AF_INET;
|
||||
addr_distant.sin_port = DEFAULTPORT;
|
||||
if (source) {
|
||||
addr_local.sin_port = DEFAULTSERVERPORT;
|
||||
} else {
|
||||
addr_local.sin_port = DEFAULTCLIENTPORT;
|
||||
}
|
||||
hp = gethostbyname(hostname);
|
||||
if (hp == NULL) {
|
||||
printf("hostname not found\n");
|
||||
|
|
載入中…
Reference in a new issue