WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

s... Socket Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

sAccept not Working

Keywords:   saccept

Question:

I'm having a problem in getting a simple LAN connection to work.

Here's the short (connector) side. This is from the sAccept example, with only the obvious items changed to match my LAN. I changed only the matching simple entries in the "listener" script, and it doesn't do *anything*. Any suggestions?

;;;The CONNECTER script
AddExtender("wwwsk34I.dll")
while 1
what=AskLine("Connecter","Enter TIME or QUOTE to get information from listener","time")
talksocket=sOpen()
ret=sConnect(talksocket,"100.100.100.10","1001")
sSendLine(talksocket,what)
response=sRecvLine(talksocket,555)
sClose(talksocket)
Message(what,response)
endwhile 

Answer:

Ummm. I guessing that the problem is that the WinSock extender only likes DNS served machines, whether or not you specify machine name by IP address or not.

In other words, the IP address has to be name served for this function to work.


Be Sure to Check IP Address:

Question:

I'm making some tests with the socket functions included in the Winsock Extender. I was testing the example described under the sAccept function topic, which includes two scripts: the first one (the "listener") opens a sockets and listens for remote connections, the second one (the "caller") connects on the remote socket and retrieve some information.

I tried to make the things work in such environment: listener put on a PC with a public address and the caller on a dial up connection. Unfortunately the whole thing didn't work, but it did simulating the caller with Telnet.

Would anyone like to help me out with some tips?

;The Talker Script:

;;;The CONNECTER script
AddExtender("WWWSK34I.dll")
while 1
   what=AskLine("Connecter","Enter TIME or QUOTE to get information from listener","QUOTE")
   talksocket=sOpen()
   ret=sConnect(talksocket,"206.63.11.252","ftp")
   sSendLine(talksocket,what)
   response=sRecvLine(talksocket,555)
   sClose(talksocket)
   Message(what,response)
endwhile


;The Listener Script:

;;;The LISTENER script
; Use CTRL-Break to exit
AddExtender("wwwsk34I.dll")

quote0="Few women admit their age, few men act it. "
quote1="Don't anthropomorphize computers. They hate that. "
quote2="ANIMAL LOVER ON BOARD. They're delicious. "
quote3="My karma ran over my dogma. "
quote4="The gene pool could use a little chlorine. "
quote5="Time is what keeps things from happening all at once. "
quote6="I didn't fight my way to the top of the food chain to be a vegetarian. "
quote7="Women who seek to be equal with men lack ambition. "
quote8="Your kid may be an honor student but you're still an idiot! "
quote9="If we aren't supposed to eat animals, why are they made with meat? "
maxquote=9


BoxOpen("Listener","")
listensocket=sOpen()
sListen(listensocket,"ftp")   ; use ftp port for lack of anything better
Served=0
while 1
   datasocket=sAccept(listensocket,@TRUE)  ; Block for a connection
   if datasocket
       gosub ProcessConnect
   else
      sClose(listenSocket)
      msg=wxGetLastErr()
      Message("Socket Error",msg)
      exit
  endif
endwhile
exit   

:ProcessConnect
         Served=Served+1
         rqst=sRecvLine(datasocket,20)
         rqst=strlower(rqst)
         if rqst=="time"
             rsp=TimeDate()
         else
            if rqst=="quote"
               mqr=random(maxquote)
               rsp=quote%mqr%
            else
               rsp="Error: Can only respond to TIME and QUOTE"
            endif
         endif
         BoxTitle(strcat("Served:",Served,"  Last=",wxGetInfo(2,datasocket)))
         BoxText(strcat(rqst," : ",rsp))
         sSendLine(datasocket,rsp)
         sClose(datasocket)
return

Answer:

The IP address in the CALL script sConnect references a defunct computer we had years ago. I think you need to put in the name of the computer you want, not our old one.

In addition, whether you specify computer name (abc.xxx.com) or IP address, the computer MUST be DNS Servered. So for exapmle if you open a DOS box and type

  ping -a 111.222.333.444 (use your IP Address)
it MUST resolve to a computer name and not just show the IP address.
Article ID:   W12667
Filename:   sAccept Not Working.txt
File Created: 2001:03:01:15:07:06
Last Updated: 2001:03:01:15:07:06