Log in

View Full Version : Can't get TCPServer() and TCPSource() to work. Need help.


Logan9778
30th March 2017, 03:12
Thanks for all the advice in the other thread.

I've been trying to get TCPServer() and TCPSource() to work on two different computers, but have not been successful. I keep getting TCPServer: bind() failed. And of course, TCPSource tells me there is no server.

Here is my code so far.

#Server
LoadPlugin("c:\program files (x86)\avisynth\plugins\nnedi.dll")
loadplugin("F:\Encoding\DCDecNV2050\DGDecodeNV.dll")
SetMTMode(5,4)
DGsource("F:\DVD Workspace\Doctor Who - Season 01\An Unearthly Child\title01.dgi")
SetMTMode(2)
QTGMC(fpsdivisor=1, Preset="placebo", edithreads=4)
Crop(8, 2, -8, -2)
TCPServer(port=53270)

#Source
TCPSource("127.0.0.1", port=53270, compression="GZip")

I'm thinking I don't know what I'm doing. :( I've searched for more info, but there appears to be very little except for the AVS Wiki.

Could someone please write me a short script ( just a shell even ) that would take one computer being an avisynth frame server and link it to another computer on the same network that is going to take the output from the server ( film frame ) and input it into Simple X264 running on the second computer? So, I would have the first computer being the Avisynth frame server and the second computer being the X264 encoder running Simple X264.

Hopefully, I can learn from the code. It appears I have to have something running the server too, like MPC-HC? I'm not quite understanding that, either.

Thanks!

Midzuki
30th March 2017, 07:08
"127.0.0.1" is the localhost, or "local loopback".
If you want to access a different computer on your intranet, you'll have to call the IP address that it received from the router.
Run ipconfig /all in a command prompt on the server machine, and look for the line that says something like this:

IPv4 Address. . . . . . . . . . . : 192.168.***.***(Preferred)

Then use that IP address in the TCPSource() script on the client machine.

StainlessS
30th March 2017, 17:47
Or from any machine to find ip address on your intranet (Domain or WorkGroup) eg

Ping some-machine

where some-machine is remote machine Computer Name, might result in something like

Pinging some-machine [192.168.11.21] with 32 bytes of data:

Reply from 192.168.11.21: bytes=32 time<1ms TTL=128
Reply from 192.168.11.21: bytes=32 time<1ms TTL=128
Reply from 192.168.11.21: bytes=32 time<1ms TTL=128
Reply from 192.168.11.21: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.11.21:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

and IP Address result is as above, 192.168.11.21

EDIT:
127.0.0.1" is the localhost, or "local loopback.
Clarification, localhost 127.0.0.1, is the machine you are sitting at. (pinging 127.0.0.1, would ping yourself)

StainlessS
30th March 2017, 18:55
Perhaps of use [req CallCmd() and RT_Stats()]


# ComputerName2IpAddress.avsi

Function ComputerName2IpAddress(String ComputerName) { # https://forum.doom9.org/showthread.php?p=1802394#post1802394
myName="ComputerName2IpAddress: "
Assert(ComputerName!="",RT_String("%sComputerName cannot be ''",myName))
FN="~ComputerName2IpAddress_"+RT_LocalTimeString(File=True)+".txt"
RT_fileDelete(FN) # paranoia.
c=BlankClip(Width=16,height=16,length=1)
HIDE=True DEBUG=True
CMD=RT_string("cmd /c ping %s >%s",ComputerName,FN)
c=c.CallCmd(Open=CMD,Hide=HIDE,debug=DEBUG)
c=0 # Call clip Destructor
Assert(Exist(FN),RT_string("%sError on Command '%s'",myName,CMD))
BadUsage=RT_FileFindStr(FN,"Usage")
Assert(BadUsage<0,RT_string("%sBad ComputerName '%s'",myName,ComputerName))
LINE=RT_FileFindStr(FN,"[")
Assert(LINE>=0,RT_string("%sRT_FileFindStr Cannot Find '[' enclosing IP Address",myName))
S=RT_ReadTxtFromFile(FN,Lines=1,Start=LINE)
RT_FileDelete(FN)
i=RT_FindStr(S,"[")
Assert(i>=1,RT_string("%sRT_FindStr Cannot Find '[' enclosing IP Address",myName))
S=MidStr(S,i+1)
i=RT_FindStr(S,"]")
Assert(i>=1,RT_string("%sRT_FindStr Cannot Find ']' enclosing IP Address",myName))
S=LeftStr(S,i-1)
Return S
}


Client

COMPUTER_NAME="Ivan-XP1" # Computer Name in WorkGroup / Domain local
#COMPUTER_NAME="www.doom9.org" # 'www.' needed here for some reason (IIRC, www. is the dns server computer for the domain) [EDIT: www.doom9.org NO LONGER ON-LINE]
#COMPUTER_NAME="forum.doom9.org" # but not needed here (forum.doom9.org is a specific server computer)
#COMPUTER_NAME="www.bbc.co.uk" # bbc dns server
#COMPUTER_NAME="bbc.co.uk" # One of a cluster of bbc servers

S=ComputerName2IpAddress(COMPUTER_NAME)
Return MessageClip(COMPUTER_NAME + " = " + S)


EDIT: Modified.

Logan9778
30th March 2017, 21:10
Wow, that's some programming there. :D I'll have to try it out. Thanks for the help. I actually got it working, but I have a new problem now. I found out my problem is that I'm using Avisynth 2.6 MT. The regular Avisynth 2.6 seems to work in AvsPmod, but when I switch over to the Avisynth 2.6 MT .dll in Windows/SysWoW, I get a "TCP Server: bind() failed" error.

Any of you guys know what's happening?

StainlessS
30th March 2017, 21:45
OK, just tried it out and

TCPSource(string hostname [, int port, string compression])


hostname can be a ComputerName OR an IP address, so above function not necessary (but maybe of use for something else).

I did though get an Access Violation when the hostname was not online (looks like v2.6 TCPSource bug).
EDIT: Ivan-XP1 is in a WorkGroup.

Above using TcpDeliver.dll as distributed by Standard Avisynth v2.6 (I think it used to be an internal filter).

Perhaps you could try using TcpDeliver() from v2.6 standard, see if it works (LoadPlugin, overrides built-in filter).

EDIT: Script 1 on Ivan-XP1 [EDIT: Start this one first]

Colorbars
ShowFrameNumber # Added
TCPServer()


Script 2 on local machine

TCPSource("Ivan-XP1")


EDIT: I just played in MPC-HC on both machines.
EDIT: Suggest NOT using AvsPMod on server machine, anything else eg MPC-HC.

Logan9778
31st March 2017, 00:43
Thanks Stainless! Yeah, it looks like the problem may be AvsPmod. I will try doing it with MPC-HC, and also your suggestion of TCpDeliver().

Though in the end, I'm finding my other two old computers aren't NEAR as powerful as I thought they were. :o