Jump to content
Excelsior Forums


  • Content count

  • Joined

  • Last visited


Community Reputation

0 Neutral

About rms

  • Rank
  • Birthday 01/01/1
  1. Yep, there are some contradictions here: connected is TRUE, yet strace says there are errors. I didn't know about strace until this thread, so I still don't know enough about it to know what to make of it all. Even that aside, I can't figure out why your connect works and mine does not, as I copied much from yours at aliboom. Anybody else aside from qrn and myself have any ideas here?
  2. rms

    Importing errno

    After a failed call, how do I check errno? Thanks
  3. I used a hard-wired 20 in my first try, lifing it straight from your code at Aliboom. It caused my program to hang while attempting to connect. When I substituted SIZE( inAddr ) or a hard-wired 8, it worked. ( just so nobody wastes their time on one other possibility: yes I should be using TSIZE(), since inAddr is a TYPE. But both SIZE() and TSIZE() return a value of 8, and the program still behaves the same. I guess the ability of SIZE() to handle not only VARs but also TYPEs is an undocumented feature. ) Any value of 0 thru 15 works ( ie: connected = TRUE ). Any value of 16 through 20 causes my program to hang. I'm going to try some higher numbers. It shouldn't work, but, then again, 20 shouldn't work in your program. I'm also going to look at the flags on the send call.
  4. Thanks, but that does not fix it. I appended the CR, nothing changed. I even considered the possibility that passing msg as a parameter might 'purify' it, so I rearranged it as follows: PROCEDURE DoSend ( s_num: Socket; msg: ARRAY OF CHAR ); VAR sent: BOOLEAN; num_sent: CARDINAL; BEGIN WriteString("Preparing to send"); WriteLn; Concat(msg,CR,msg); WriteString( msg ); WriteLn; num_sent := send( s_num, msg, LENGTH( msg ), 0 ); sent := ( MAX( CARDINAL ) <> num_sent ); IF sent THEN WriteString("Sent data ok"); WriteLn; ELSE WriteString("Error when trying to send. Number sent ="); WriteCard( num_sent, 10 ); WriteLn; END; END DoSend; Nothing changed. So I was beginning to suspect that msg is not the problem. As a test, I tried sent := send( s_num, 0, 0, 0 ); Still no change. I don't think that msg is the problem.
  5. I'm trying to use 'send' from PMOS. It fails. It does not generate any error messages, the program simply terminates prematurely. The following is it's output: hep = 10609036 Got socket # 3 Preparing to call connect Got a connection Preparing to send And that is it. It hits the 'send' call and halts. It does not write Ending main line of Sock02, or even the value of 'sent'. Anybody know how to fix it? Or at lease how to delay termination long enough to get an error message? Thanks. The following is the program: <*+ M2EXTENSIONS *> <*+ M2ADDTYPES *> <*+ CSTDLIB *> MODULE Sock02; FROM NetDB IMPORT gethostbyname, HostEntPtr; FROM Sockets IMPORT Socket, send, recv; FROM Strings IMPORT Assign, Concat; FROM STextIO IMPORT WriteString, WriteLn, WriteChar; FROM SYSTEM IMPORT CARD16, CARD32, LOC, INT32, TSIZE; FROM Storage IMPORT ALLOCATE; FROM InOut IMPORT WriteInt, WriteCard; CONST maxChars = 512; TYPE AddressFamily = (AF_UNSPEC, AF_UNIX, AF_INET, AF_IMPLINK, AF_PUP, AF_CHAOS, AF_NS, AF_NBS, AF_ECMA, AF_DATAKIT, AF_CCITT, AF_SNA, AF_DECnet, AF_DLI, AF_LAT, AF_HYLINK, AF_APPLETALK, AF_NETBIOS, AF_MAX); Addr = RECORD addr : CARD32; END; (* RECORD Addr*) inAddr = RECORD family : CARD16 (*AddressFamily*); port : CARD16; s_addr : Addr; END; (* RECORD inAddr *) strType = ARRAY [0..maxChars] OF CHAR; VAR serv : Socket; PROCEDURE ["C"] / bind ( socket : Socket; VAR myAddr : inAddr; addrlen : CARDINAL ) : BOOLEAN; PROCEDURE ["C"] / connect ( socket : CARDINAL; servAddr : inAddr; addrlen : CARDINAL ) : BOOLEAN; PROCEDURE ["C"] / htons ( numb : CARD16 ) : CARD16; PROCEDURE ["C"] / htonl ( numb : CARD32 ) : CARD32; PROCEDURE ["C"] / socket( domain : CARDINAL; type : CARDINAL; protocol : CARDINAL ) : CARDINAL; TYPE Recv_buf = ARRAY[ 1..1000 ] OF CHAR; Recv_buf_ptr = POINTER TO Recv_buf; Send_buf = ARRAY[ 1..10 ] OF CHAR; Send_buf_ptr = POINTER TO Send_buf; VAR i: INTEGER; sock_num: Socket; recv_buf_ptr: Recv_buf_ptr; send_buf_ptr: Send_buf_ptr; hep: HostEntPtr ; service_name: ARRAY[ 1..20 ] OF CHAR; serv_addr: inAddr; connected, sent, received: BOOLEAN; port, num_sent, num_received: CARDINAL; msg: strType; BEGIN service_name := 'www.yahoo.com'; hep := gethostbyname( service_name ); WriteString("hep = "); WriteInt( INT32( hep ), 10 ); WriteLn; sock_num := socket( 2, 1, CARD32( AF_NS ) ); IF sock_num < 1 THEN WriteString("Can't get a socket"); WriteLn; ELSE WriteString("Got socket #"); WriteInt( sock_num, 2 ); WriteLn; END; port := 9999; serv_addr.s_addr.addr := CARD32( hep^.h_addr_list^[0]^ ); serv_addr.family := 2 (* AF_INET *); serv_addr.port := htons( CARD16(port) ) ; WriteString("Preparing to call connect"); WriteLn; connected := connect( sock_num, serv_addr, SIZE( inAddr ) ); IF connected THEN WriteString("Got a connection"); WriteLn; ELSE WriteString("Can't get a connection"); WriteLn; END; IF connected THEN WriteString("Preparing to send"); WriteLn; (* this send call - instead of using allocate and msg - generates same failure msg := "test"; num_sent := send( sock_num, msg, LENGTH( msg ), 0 ); *) ALLOCATE( send_buf_ptr, TSIZE(Send_buf) ); send_buf_ptr^ := "test"; num_sent := send( sock_num, send_buf_ptr, LENGTH( send_buf_ptr^ ), 0 ); (**DIES HERE**) sent := ( MAX( CARDINAL ) <> num_sent ); IF sent THEN WriteString("Sent data ok"); WriteLn; ELSE WriteString("Error when trying to send. Number sent ="); WriteCard( num_sent, 10 ); WriteLn; END; END; IF sent THEN ALLOCATE( recv_buf_ptr, TSIZE(Recv_buf) ); FOR i := 1 TO 100 DO recv_buf_ptr^ := 'x'; END; num_received := recv( sock_num, recv_buf_ptr, TSIZE(Recv_buf), 0 ); received := ( MAX( CARDINAL ) <> num_received ); END; IF received THEN FOR i := 1 TO 100 DO IF ( ORD( recv_buf_ptr^ ) > ORD('A') ) AND ( ORD( recv_buf_ptr^ ) < ORD('z') ) THEN WriteChar ( recv_buf_ptr^ ); ELSE WriteChar ( '.' ); END; END; WriteLn; ELSE WriteString( "Error when receiving " ); WriteLn; END; WriteString("Ending main line of Sock02"); WriteLn; END Sock02.
  6. I want to use the GTK+ package with Modula. I assume that I could write a wrapper for all the calls, compile it, use H2D to create a .DEF file, and import it. Does this sound reasonable? Am I missing an important step, or a shortcut? Also, has anybody else done this? I don't want to reinvent the wheel. Thanks Robert ( PS: the handle is not bizarre Stallman worship; it really is my initials )