c functions usage on D3

35 views
Skip to first unread message

philippe GRACIA

unread,
Oct 30, 2025, 11:04:22 AM (4 days ago) Oct 30
to mvd...@googlegroups.com
can someone help use on using C socket functions on D3 10.3 ?
we're trying to set timeout on incoming connections using %setsockopt without success ...
thanks for your help !

Nivethan T

unread,
Oct 31, 2025, 9:54:26 AM (3 days ago) Oct 31
to Pick and MultiValue Databases
Could you post some sample code and the OS you're using?

philippe GRACIA

unread,
Oct 31, 2025, 10:48:18 AM (3 days ago) Oct 31
to mvd...@googlegroups.com
hello!
D3 linux 10.3.4 on redhat 8.4
very simple code ( from the doc, but setsockopt is very poorly documented !)

 'test.socket' size = 1086                                  
      cfunction socket.builtin                              
      include dm,bp,includes sysid.inc                      
      include dm,bp,unix.h socket.h                        
* Create a socket                                          
      listen.port=4062                                      
      buffer.size=1024                                      
      timeout=255                                                                                                    
      fd=%socket(af$inet, sock$stream, 0)                  
******* <- here !                                          
      ret=%setsockopt(fd,SOL$SOCKET,SO$RCVTIMEO, timeout,1)
      print ret                                            
* Bind the socket to a local Ethernet port.                
* Use default address.                                      
      char buffer[buffer.size]                              
      if %bind(fd, af$inet, inaddr$any, listen.port)<0 then
         crt "bind failed"; stop                            
      end                                                  
* Wait for incoming connection and allow up to              
* three more to be waiting.                                
      %listen(fd, 3)                                        
*      debug                                                
* Accept a connection until got them all                    
      loop                                                  
      address=0; port=0                                    
      socket=%accept(fd, &address, &port)           
      until socket<0 do                                    
      crt "Called by address ":address:", port #":port      
* Read data from the data link                              
      %recv(socket, buffer, buffer.size)                    
* Done with this connection, close it                      
      print trim(buffer)                                    

      char buffer[buffer.size] ; * re-init                  
      %closesocket(socket)                                  
      repeat                                                


--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvdbms+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mvdbms/9c33c5e8-a94e-4e41-9bc7-4f5b0432bb43n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages