aboutsummaryrefslogtreecommitdiff
path: root/src/Sockets.c
diff options
context:
space:
mode:
authorjshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2000-10-09 23:02:27 +0000
committerjshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2000-10-09 23:02:27 +0000
commit6e58da114dfe3b00df6a3a307dcc140d547c06d8 (patch)
tree672083fa3572a42398dea678efabf2ba1ca4e8a6 /src/Sockets.c
parent52dbed6e928d2882b0c0f7005a0e269755dea5a2 (diff)
Now we have steering too.
I'm not really doing a sufficient amount of checking on the steering, but it works as long as you send "properly formed" commands. I'll do a pass on error-checking/correcting after I get IsoView updated in CVS. So now the C-version of the isosurfacer does pretty much everything that the C++ version does (aside from depending on external modules for communication/steering that is). I left the HDF5 remote sending commented out. However, since the HDF5 stream is in fact also written in C, it should be able to work. If someone wants to just check the arguments on that as well as the #defines to enable it, that should work as well. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@11 bfcf8e34-485d-4d46-a995-1fd6fa6fb178
Diffstat (limited to 'src/Sockets.c')
-rw-r--r--src/Sockets.c56
1 files changed, 43 insertions, 13 deletions
diff --git a/src/Sockets.c b/src/Sockets.c
index fea3c92..322b628 100644
--- a/src/Sockets.c
+++ b/src/Sockets.c
@@ -71,6 +71,7 @@ CCTK_FILEVERSION(DevThorns_isosurfacer_Socket_c)
#define MSG_NOSIGNAL 0
#endif
+
typedef enum {closed, open} isoSocketState;
typedef struct ISOSocket
@@ -85,6 +86,7 @@ typedef struct ISOSocket
********************* Local Routine Prototypes *********************
********************************************************************/
+IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd);
int Iso_Write(isoSocket *connection, const char *buffer, size_t count);
static SOCKET Iso_MakeSocket (unsigned long port, int *hunt);
@@ -95,7 +97,7 @@ static void SocketClose(isoSocket *this);
static int InitialiseTCP(void);
-static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this);
+static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this,IsoCommand *cmd);
/********************************************************************
********************* Other Routine Prototypes *********************
@@ -342,22 +344,46 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec)
SocketCreate(new, &controlsocklist);
}
+
+ return 0;
+}
+
+IsoCommand *Iso_PollCommand(cGH *cctkGH,IsoCommand *cmd){
+#ifdef HAVE_SOCKLEN_T
+ socklen_t size;
+#else
+ int size;
+#endif
+ fd_set read_fd_set;
+ struct sockaddr_in clientname;
+ struct timeval timeout;
+ struct timeval *real_timeout;
+
+ isoSocket *this;
+ isoSocket *next;
+ /* always a timeout of 0 */
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ real_timeout = &timeout;
- for(this = controlsocklist; this; this = next)
- {
- next = this->next;
- if(FD_ISSET (this->filedes, &read_fd_set))
- {
+ /* Check if any input is available on one or more active sockets. */
+ read_fd_set = active_fd_set;
+
+ if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))){
+ perror ("select");
+ CCTK_Abort(cctkGH, EXIT_FAILURE);
+ }
+ /* get next command on the control socket list */
+ for(this = controlsocklist; this; this = this->next){
+ if(FD_ISSET (this->filedes, &read_fd_set)){
/* Data arriving on an already-connected socket. */
- if (Iso_ReadFromClient (cctkGH, this) < 0)
- {
- SocketDestroy(this, &controlsocklist);
+ if (Iso_Read (this, cmd->buffer,64+64+64) <= 0){
+ SocketDestroy(this, &controlsocklist);
}
+ else return cmd; /* return immediately with the new command (first available) */
}
}
-
-
- return 0;
+ return NULL;
}
int IsoWriteDataToClients(const char *metadata,
@@ -801,8 +827,12 @@ static void SocketClose(isoSocket *this)
@endhistory
@@*/
-static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this)
+static int Iso_ReadFromClient(cGH *cctkGH, isoSocket *this,IsoCommand *command)
{
+ /* Need to have 64+64+64 buffer here (datastruct)
+ put the buffer in a union.
+ */
+
return -1;
}