Skip to content
Snippets Groups Projects
Commit 412864a5 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

*** empty log message ***

parent 46094ed5
No related branches found
No related tags found
No related merge requests found
......@@ -39,14 +39,24 @@ int WaitForData(int socket, int num, int pollint, double waitint);
#if defined(_AIX)
#include <strings.h>
#endif
#if !defined(WIN32) || defined(__CYGWIN__)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <sys/un.h>
#include <sys/time.h>
#include <unistd.h>
#include <netinet/in.h>
#else // pure windows
#include <winsock2.h>
#endif
class GmshServer {
public:
// This should match what's in GmshClient.h
......@@ -74,7 +84,7 @@ class GmshServer {
int sofar = 0;
int remaining = bytes;
do {
int len = read(_sock, buf + sofar, remaining);
ssize_t len = recv(_sock, buf + sofar, remaining, 0);
if(len <= 0)
return 0;
sofar += len;
......@@ -132,7 +142,9 @@ class GmshServer {
if(_portno < 0){
// delete the file if it already exists
#if !defined(WIN32) || defined(__CYGWIN__)
unlink(_sockname);
#endif
// make the socket
s = socket(PF_UNIX, SOCK_STREAM, 0);
......@@ -218,8 +230,10 @@ class GmshServer {
{
if(_portno < 0){
// UNIX socket
#if !defined(WIN32) || defined(__CYGWIN__)
if(unlink(_sockname) == -1)
return -1; // Impossible to unlink the socket
#endif
}
close(_sock);
return 0;
......
// $Id: Solvers.cpp,v 1.39 2005-08-31 21:44:44 geuzaine Exp $
// $Id: Solvers.cpp,v 1.40 2005-09-25 18:51:27 geuzaine Exp $
//
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
//
......@@ -24,8 +24,6 @@
SolverInfo SINFO[MAXSOLVERS];
#if !defined(WIN32) || defined(__CYGWIN__)
#include "GmshServer.h"
// FIXME: this should be removed (and we should set the socket options
......@@ -33,13 +31,6 @@ SolverInfo SINFO[MAXSOLVERS];
int GmshServer::init = 0;
int GmshServer::s;
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <sys/un.h>
#include <unistd.h>
#include "OpenFile.h"
#include "GmshUI.h"
#include "GUI.h"
......@@ -281,13 +272,3 @@ int Solver(int num, char *args)
return 1;
}
#else // pure windows
int Solver(int num, char *args)
{
Msg(GERROR, "Solver interface not available on Windows without Cygwin");
return 1;
}
#endif
......@@ -33,6 +33,9 @@
#ifdef _AIX
#include <strings.h>
#endif
#if !defined(WIN32) || defined(__CYGWIN__)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
......@@ -42,6 +45,12 @@
#include <netinet/in.h>
#include <netdb.h>
#else // pure windows
#include <winsock2.h>
#endif
class GmshClient {
private:
typedef enum{ CLIENT_START = 1,
......@@ -63,7 +72,7 @@ class GmshClient {
int sofar = 0;
int remaining = bytes;
do {
int len = write(_sock, buf + sofar, remaining);
ssize_t len = send(_sock, buf + sofar, remaining, 0);
sofar += len;
remaining -= len;
} while(remaining > 0);
......@@ -77,17 +86,23 @@ class GmshClient {
}
long _GetTime()
{
#if !defined(WIN32) || defined(__CYGWIN__)
struct timeval tp;
gettimeofday(&tp, (struct timezone *)0);
return (long)tp.tv_sec * 1000000 + (long)tp.tv_usec;
#else
return 0;
#endif
}
void _Idle(double delay)
{
#if !defined(WIN32) || defined(__CYGWIN__)
long t1 = _GetTime();
while(1) {
if(_GetTime() - t1 > 1.e6 * delay)
break;
}
#endif
}
public:
GmshClient() : _sock(0) {}
......
/* $Id: GmshClient.c,v 1.3 2005-01-16 20:56:03 geuzaine Exp $ */
/* $Id: GmshClient.c,v 1.4 2005-09-25 18:51:27 geuzaine Exp $ */
/*
* Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
*
......@@ -36,6 +36,9 @@
#ifdef _AIX
#include <strings.h>
#endif
#if !defined(WIN32) || defined(__CYGWIN__)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
......@@ -45,17 +48,24 @@
#include <netinet/in.h>
#include <netdb.h>
#else /* pure windows */
#include <winsock2.h>
#endif
/* private functions */
static void Socket_SendData(int socket, void *buffer, int bytes)
{
int sofar, remaining, len;
ssize_t len;
int sofar, remaining;
char *buf;
buf = (char *)buffer;
sofar = 0;
remaining = bytes;
do {
len = write(socket, buf + sofar, remaining);
len = send(socket, buf + sofar, remaining, 0);
sofar += len;
remaining -= len;
} while(remaining > 0);
......@@ -63,18 +73,24 @@ static void Socket_SendData(int socket, void *buffer, int bytes)
static long Socket_GetTime()
{
#if !defined(WIN32) || defined(__CYGWIN__)
struct timeval tp;
gettimeofday(&tp, (struct timezone *)0);
return (long)tp.tv_sec * 1000000 + (long)tp.tv_usec;
#else
return 0;
#endif
}
static void Socket_Idle(double delay)
{
#if !defined(WIN32) || defined(__CYGWIN__)
long t1 = Socket_GetTime();
while(1) {
if(Socket_GetTime() - t1 > 1.e6 * delay)
break;
}
#endif
}
/* public interface */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment