News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

mk:

Started by oex, March 24, 2010, 12:29:26 AM

Previous topic - Next topic

oex

I think this is an easy one, I'm trying to get my sockets code to connect to mk:@MSITStore: urls.... I'm assuming http get request is normal but it's erroring somewhere here:

   invoke gethostbyname, chr$("localhost")   ; I think issue lies here?
   cmp eax, 0
   je InvalidHost

   mov eax,(hostent ptr [eax]).h_list
   mov eax,[eax]
   mov eax,[eax]
   mov sin.sin_addr,eax

   invoke socket, AF_INET, SOCK_STREAM, IPPROTO_TCP
   cmp eax, INVALID_SOCKET
   je InvalidSocket

   mov hSock, eax

   invoke htons, 80

   mov sin.sin_port,ax
   mov sin.sin_family,AF_INET

   invoke connect, hSock, ADDR sin, SIZEOF sin
   cmp eax, SOCKET_ERROR
   je SocketError

Fails here
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

theunknownguy

Some example i use for my emulator connection with internal clients:

;/////////////////////////////////////////////////////////
;Custom proc for make an Host address from input arguments
;and save the address in TCP/UDP struct
;RETURN VALUES: 1 == SUCCESS, 0 == FAILURE
;/////////////////////////////////////////////////////////
V_Sock_MakeAddr Proc Uses Ecx IPorName:DWord, Port:DWord
Local MyStruct:DWord
assume ecx:ptr InternalClients_Struct
lea ecx, [ecx].SockAddr
Assume Ecx:Ptr sockaddr_in
Push Ecx
Invoke ntohs, Port
Pop Ecx
Mov [Ecx].sin_family, 2
Mov [Ecx].sin_port, Ax
push ecx
Invoke inet_addr, IPorName ;Take by IP
pop ecx
Mov [Ecx].sin_addr, Eax
mov MyStruct, ecx ;Save for now struct in a variable
.If (Eax == -1)
Invoke gethostbyname, IPorName ;Take by Host Name
  .If (Eax == 0)
  .Else
     Assume Eax:Ptr hostent
     Mov Ecx, MyStruct
      Mov Edx, DWord Ptr [Eax].h_list
      Mov Ebx, [Edx] ;EBX = Host name converted
     Invoke MemCopy, Ebx, Addr [Ecx].sin_addr, [Eax].h_len ;Save into sin_addr in our struct
  .EndIf
.EndIf
Assume Ecx:Nothing
assume eax:Nothing
Ret
V_Sock_MakeAddr EndP


We pretty much have the same:


Invoke gethostbyname, IPorName ;Take by Host Name
Invoke connect, [Ecx].Sock, addr [Ecx].SockAddr, SizeOf sockaddr_in




oex

what host name do you use for local call? IPorName, Grrr I have working code on my other drive but I dont have it :lol....

This should return 127.0.0.1 and then it *should* work
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

theunknownguy

Quote from: oex on March 24, 2010, 12:48:09 AM
what host name do you use for local call? IPorName, Grrr I have working code on my other drive but I dont have it :lol

Its on a config file this one is:


//------------------------------------------------------//
//          Connect Server Options                 //
//------------------------------------------------------//
ConnectServerIP                         = indig.sytes.net
ConnectServerPort                       = 55557

oex

I can connect to domain.ext no problems just not 127.0.0.1 (localhost)
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

theunknownguy

Quote from: oex on March 24, 2010, 12:51:48 AM
I can connect to domain.ext no problems just not 127.0.0.1 (localhost)

I can connect to localhot with no problem... look the datas from my config file:


//------------------------------------------------------//
//          Data Servers Options                 //
//------------------------------------------------------//
DataServerIP1                           = 127.0.0.1
DataServerIP2                           = 127.0.0.1
DataServerPort1                         = 55960
DataServerPort2                         = 55962

//------------------------------------------------------//
//          ExDB Server Options                 //
//------------------------------------------------------//
ExDBServerIP                            = 127.0.0.1
ExDBPort                                = 55906

//------------------------------------------------------//
//          Joyn Server Options                 //
//------------------------------------------------------//
JoynServerIP                            = 127.0.0.1
JoynServerPort                          = 55970

//------------------------------------------------------//
//          Connect Server Options                 //
//------------------------------------------------------//
ConnectServerIP                         = indig.sytes.net
ConnectServerPort                       = 55557


Some kind of firewall or something?

oex

maybe firewall yeah, just dug further and it is returning 127.0.0.1 and failing at connect.... firewall not popping up though....

Maybe mk:@MSITStore: not at port 80?
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

theunknownguy

Quote from: oex on March 24, 2010, 12:59:48 AM
maybe firewall yeah, just dug further and it is returning 127.0.0.1 and failing at connect.... firewall not popping up though....

Maybe mk:@MSITStore: not at port 80?

Havent try on port 80 i never use that port, but i think it shouldnt make much of a difference, try setting another port and if you can use NO-IP for create your own "address base" name instead of "localhost".

But again it should be the same...

Gunner

Quote from: oex on March 24, 2010, 12:29:26 AM
I think this is an easy one, I'm trying to get my sockets code to connect to mk:@MSITStore: urls.... I'm assuming http get request is normal but it's erroring somewhere here:

   invoke gethostbyname, chr$("localhost")   ; I think issue lies here?
   cmp eax, 0
   je InvalidHost

   mov eax,(hostent ptr [eax]).h_list
   mov eax,[eax]
   mov eax,[eax]
   mov sin.sin_addr,eax

   invoke socket, AF_INET, SOCK_STREAM, IPPROTO_TCP
   cmp eax, INVALID_SOCKET
   je InvalidSocket

   mov hSock, eax

   invoke htons, 80

   mov sin.sin_port,ax
   mov sin.sin_family,AF_INET

   invoke connect, hSock, ADDR sin, SIZEOF sin
   cmp eax, SOCKET_ERROR
   je SocketError

Fails here

mk:@MSITStore opens chm files *only* on the local computer (I read that somewhere) what are you trying to do exactly?
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

oex

I just want to access help file source in my app.... I have found a crappy way using:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/vscondecomp.asp
HH.EXE -decompile [folder] [chm]

but I'd rather not piss around and have to reserve folder namespace and call an external app that may or may not exist wher I expect it :lol but rather access the mk: url through sockets like the browser does ie like goto mk:@MSITStore:C:\HelpFile.chm::/index.htm in IE

I'm assuming the protocol returns the *uncompressed* html and I have no way to get file names yet other than get properties on the actual doc (although I have found chm file format somewhere)

I'd just like to add some functionality to chm viewer *locally*. I thought it would just be a question of connecting to local host and placing the path in a http request but it's not even connecting to localhost ::).


EDIT: Not to worry I'm doing it the crappy way for now :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv