Cleaned up ANSTO code to merge with sinqdev.sics
This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c Conflicts: .gitignore SICSmain.c asynnet.c confvirtualmot.c counter.c devexec.c drive.c event.h exebuf.c exeman.c histmem.c interface.h motor.c motorlist.c motorsec.c multicounter.c napi.c napi.h napi4.c network.c nwatch.c nxscript.c nxxml.c nxxml.h ofac.c reflist.c scan.c sicshipadaba.c sicsobj.c site_ansto/docs/Copyright.txt site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl statusfile.c tasdrive.c tasub.c tasub.h tasublib.c tasublib.h
This commit is contained in:
28
asynnet.c
28
asynnet.c
@ -46,6 +46,7 @@
|
||||
#define RBUFFERSIZE 262144 /* 256kb */
|
||||
#define WBUFFERSIZE 20*262144
|
||||
/* #define WBUFFERSIZE 100*262144 */
|
||||
#define MAXWBUFFERSIZE 128*1000*1024
|
||||
/*--------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
int socket;
|
||||
@ -204,7 +205,7 @@ int ANETregisterSocket(int socket)
|
||||
flags =1;
|
||||
setsockopt(socket,IPPROTO_TCP,TCP_NODELAY,(char *) &flags, sizeof(int));
|
||||
socke.readBuffer = MakeRWPuffer(RBUFFERSIZE);
|
||||
socke.writeBuffer = MakeRWPuffer(WBUFFERSIZE);
|
||||
socke.writeBuffer = MakeBigRWPuffer(WBUFFERSIZE, MAXWBUFFERSIZE);
|
||||
if (socke.readBuffer == NULL || socke.writeBuffer == NULL) {
|
||||
return ANETMEM;
|
||||
}
|
||||
@ -247,6 +248,7 @@ int ANETconnect(char *name, int iPort)
|
||||
status = connect(socke, (struct sockaddr *) &addresse,
|
||||
sizeof(struct sockaddr_in));
|
||||
if (status < 0) {
|
||||
close(socke);
|
||||
anetLog(ANETERROR, "Failed to open socket to %s:%d", name, iPort);
|
||||
return ANETOPENFAIL;
|
||||
}
|
||||
@ -503,7 +505,20 @@ int ANETinfo(int handle, char *hostname, int hostnameLen)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int ANETcanWrite(int handle, void *buffer, int count)
|
||||
{
|
||||
pSocketDescriptor con = NULL;
|
||||
int status;
|
||||
|
||||
con = findSocketDescriptor(handle);
|
||||
if (con == NULL) {
|
||||
return ANETDISCONNECTED;
|
||||
} else {
|
||||
ANETprocess();
|
||||
return CanStoreRWBuffer(con->writeBuffer, buffer, count);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int ANETwrite(int handle, void *buffer, int count)
|
||||
{
|
||||
@ -632,14 +647,3 @@ int ANETreadTillTerm(int handle,
|
||||
}
|
||||
return ANETTIMEOUT;
|
||||
}
|
||||
|
||||
char *ANETgetWBuffer(int handle) {
|
||||
pSocketDescriptor sock;
|
||||
int len;
|
||||
char *wdata;
|
||||
|
||||
sock = findSocketDescriptor(handle);
|
||||
wdata = (char *) GetRWBufferData(sock->writeBuffer, &len);
|
||||
wdata[len] = '\0';
|
||||
return wdata;
|
||||
}
|
||||
|
Reference in New Issue
Block a user