Fixed.
This commit is contained in:
parent
d5c255aca6
commit
25cc5d2c12
4
addr.cpp
4
addr.cpp
@ -42,6 +42,10 @@ socklen_t Addr::size(void){
|
||||
return addr_size;
|
||||
}
|
||||
|
||||
void Addr::SetSize(void){
|
||||
addr_size = sizeof(address);
|
||||
}
|
||||
|
||||
void Addr::SetPort(int port){
|
||||
address.sin_port = htons(port);
|
||||
addr_size = sizeof(address);
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
try {
|
||||
Server client("127.0.0.1",9049,"127.0.0.1",9048);
|
||||
vector<int> fargs = {1,0,0,1};
|
||||
|
2
clock.h
2
clock.h
@ -19,7 +19,7 @@ struct clock_register{
|
||||
};
|
||||
|
||||
//初始化全局时钟
|
||||
void initClock(void)
|
||||
void initClock(void);
|
||||
//设置全局线程时钟
|
||||
void setThreadsClock(void);
|
||||
//时钟滴答调用函数
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "server.h"
|
||||
|
||||
class CThread;
|
||||
class Server;
|
||||
|
||||
//线程信息记录结构体
|
||||
struct thread_args{
|
||||
|
2
net.h
2
net.h
@ -30,6 +30,8 @@ public:
|
||||
void SetPort(int port);
|
||||
// 重新设置IP地址管理结构所对应的IP地址
|
||||
void SetIP(string ip_addr);
|
||||
// IP地址管理结构的大小变量
|
||||
void SetSize(void);
|
||||
// 获得指向IP地址管理结构的指针
|
||||
struct sockaddr *obj(void);
|
||||
};
|
||||
|
2
server.h
2
server.h
@ -109,6 +109,4 @@ void setServerClock(Server *psvr, int clicks);
|
||||
//服务器守护线程
|
||||
void *serverDeamon(void *psvr);
|
||||
|
||||
|
||||
|
||||
#endif /* server_h */
|
||||
|
11
socket.cpp
11
socket.cpp
@ -10,14 +10,15 @@
|
||||
|
||||
|
||||
Socket::Socket(string ip_addr, int port, bool server, bool tcp, bool ipv4){
|
||||
struct sockaddr_in &address = *(struct sockaddr_in *)addr.obj();
|
||||
if(ipv4)
|
||||
addr.address.sin_family = AF_INET;
|
||||
address.sin_family = AF_INET;
|
||||
else
|
||||
addr.address.sin_family = AF_INET6;
|
||||
addr.address.sin_port = htons(port);
|
||||
address.sin_family = AF_INET6;
|
||||
address.sin_port = htons(port);
|
||||
this->port = port;
|
||||
addr.address.sin_addr.s_addr = inet_addr(ip_addr.data());
|
||||
addr.setSize();
|
||||
address.sin_addr.s_addr = inet_addr(ip_addr.data());
|
||||
addr.SetSize();
|
||||
this->server = server;
|
||||
this->tcp = tcp;
|
||||
this->ipv4 = ipv4;
|
||||
|
3
type.h
3
type.h
@ -23,14 +23,15 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
Loading…
Reference in New Issue
Block a user