forked from scott/threaded_network_chat
update modified-example.cc to match new column limit
This commit is contained in:
@@ -86,8 +86,9 @@ displayFile(string path, int startLineNum = 0, int numLines = 10)
|
|||||||
|
|
||||||
// print each line directly to the screen
|
// print each line directly to the screen
|
||||||
int num = 0;
|
int num = 0;
|
||||||
while (getline(file, line) && num <= numLines + startLineNum + 1) // while there is file content and the
|
while (getline(file, line) &&
|
||||||
// line number isn't too high
|
num <= numLines + startLineNum + 1) // while there is file content and the
|
||||||
|
// line number isn't too high
|
||||||
{
|
{
|
||||||
if (num >= startLineNum) {
|
if (num >= startLineNum) {
|
||||||
move(lineNum, 0);
|
move(lineNum, 0);
|
||||||
@@ -132,7 +133,8 @@ void *
|
|||||||
waitForClient(void *argss)
|
waitForClient(void *argss)
|
||||||
{
|
{
|
||||||
waitClientArgs *args = static_cast<waitClientArgs *>(argss);
|
waitClientArgs *args = static_cast<waitClientArgs *>(argss);
|
||||||
clientSocketDescriptor = accept(serverSocketDescriptor, (sockaddr *)&args->newSockAddr, &args->newSockAddrSize);
|
clientSocketDescriptor =
|
||||||
|
accept(serverSocketDescriptor, (sockaddr *)&args->newSockAddr, &args->newSockAddrSize);
|
||||||
if (clientSocketDescriptor >= 0) {
|
if (clientSocketDescriptor >= 0) {
|
||||||
writeToFile(logFileName, "client connected");
|
writeToFile(logFileName, "client connected");
|
||||||
if (linesInFile(logFileName) > LOG_LENGTH)
|
if (linesInFile(logFileName) > LOG_LENGTH)
|
||||||
@@ -184,7 +186,8 @@ setupServer(int port)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
// bind the socket to its local address
|
// bind the socket to its local address
|
||||||
int bindStatus = bind(serverSocketDescriptor, (struct sockaddr *)&servAddr, sizeof(servAddr));
|
int bindStatus =
|
||||||
|
bind(serverSocketDescriptor, (struct sockaddr *)&servAddr, sizeof(servAddr));
|
||||||
if (bindStatus < 0) {
|
if (bindStatus < 0) {
|
||||||
// keeps from bricking the terminal if this happens
|
// keeps from bricking the terminal if this happens
|
||||||
endwin();
|
endwin();
|
||||||
@@ -288,7 +291,8 @@ setupClient()
|
|||||||
sendSockAddr.sin_port = htons(PORT_NUM);
|
sendSockAddr.sin_port = htons(PORT_NUM);
|
||||||
clientSocketDescriptor = socket(AF_INET, SOCK_STREAM, 0);
|
clientSocketDescriptor = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
// try to connect...
|
// try to connect...
|
||||||
int status = connect(clientSocketDescriptor, (sockaddr *)&sendSockAddr, sizeof(sendSockAddr));
|
int status =
|
||||||
|
connect(clientSocketDescriptor, (sockaddr *)&sendSockAddr, sizeof(sendSockAddr));
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
writeToFile(logFileName, "Error connecting to socket!");
|
writeToFile(logFileName, "Error connecting to socket!");
|
||||||
writeToFile(logFileName, "Connected to the server!");
|
writeToFile(logFileName, "Connected to the server!");
|
||||||
|
|||||||
Reference in New Issue
Block a user