PDA

Click to See Complete Forum and Search --> : Urgent help in ASP and COM


Chris
Nov 15th, 2000, 08:25 PM
I juz create a simple web site running in IIS 4.0 and MTS 2.0 under WinNT 4.0 server with the following files:

Global.asa

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
set Session("obj") = server.CreateObject("MapSocket.MapServer")
</SCRIPT>


winsock.asp

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<P>
<%
set obj = Session("obj")
obj.openport(2000)
%>
</P>
</BODY>
</HTML>


Sendfile.asp

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
set obj = session("obj")
obj.Send2Client("C:\testing.txt")
%>
</BODY>
</HTML>


Okay, let me briefly describe what my asp page does.
1. It will create a Object with the COM write by me in VB 6.0. This COM will open a winsock socket with port number provided by the OpenPort method as show in the winsock.asp above and listen all the client that wish to connect to the server.

2. If the is somebody post a new file by accessing the asp page sendfile.asp as show above, the sendfile.asp will call the Send2Client method as provided by the MapSocket's COM object.

Expected Result
Hence, each connected client will be able to received a new posted file name in thier client interface through the winscok socket that connected to the server.

Problem

Okay, here is my problem, when I try to run the asp page and client on the local server (installed IIS, MTS and Window 2000 server, BUT not a web server) everything is fine and the result is what i expected.

Once, I upload all this asp page and COM into the real web server with fixed IP and URL (installed WinNT 4.0 server with SP6, IIS 4.0, MTS 2.0) I only can manage to open the winsock port (by accessing the winsock.asp page). If there is any new posted file (by accessing the sendfile.asp) all the client will not be able to received the message in thier client interface.


Can anyone give me some hint what this happen in my situation? And how am I going to resolve it. Will this problem related to the server access right issue?

10X for those reply this thread.

regards
Chris.C




[Edited by Chris on 11-15-2000 at 09:29 PM]

monte96
Nov 15th, 2000, 10:29 PM
I would suspect that it is either a rights issue or the com object is not registered on the web server.

Chris
Nov 16th, 2000, 12:49 AM
I found that the error is from the COM object.


'Method under the Class module (MapServer.cls)
Public Function Send2Client(ByVal data As String)
Dim i As Integer
For i = 0 To Idx - 1
'Here is the problem, my code seem to loss the f() array
'All array() is nothing
If Not f(i) Is Nothing Then
If f(i).Winsock1.State <> sckClosed Then
f(i).Winsock1.SendData data
End If
End If
DELAY 800
Next
End Function

Public Function OpenPort(ByVal port As Integer) As Boolean
With frmServer.Winsock1
If .State <> sckClosed Then .Close
.LocalPort = port
.Listen
End With

OpenPort = True
Idx = 0
Idx2 = 0
Exit Function
OpenPort_Err:
OpenPort = False
End Function

'Declaration under the module file (Params.bas)
Global f() As frmSocket
Global c() As String
Global i() As Integer
Global Idx As Integer
Global Idx2 As Integer

'Code under the frmServer
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
'Resize the array
ReDim Preserve f(Idx)

'Create new frmSocket
Set f(Idx) = New frmSocket

'Store the Object index
f(Idx).Tag = Idx
'Accept the winsock connection
f(Idx).Winsock1.Accept requestID
'Load the form
Load f(Idx)

'Increase counter by 1
'Idx = Idx + 1
End Sub


Problem
How can I hold the Array f() object in the Class module. or ceate a global access array in Class module?

Why the Idx and Idx2 value always reset to 0 in the Send2Client method. Although I did increase the counter in the Winsock1_ConnectionRequest event of the frmServer. WHY?

But with the same code, it running fine under the Win2000 Server+IIS+MTS. WHY?

regards,
Chris.C

Chris
Nov 16th, 2000, 05:16 AM
I Juz resolve my problem with another solution. Does anyone know to create a Object once only (when I start a asp page) and let the Object remain active till the server is shutdoen/restart.

hence, others ASp can access this object method with all the dynamic array remain unchange or lost.

regards,
Chris.C

monte96
Nov 16th, 2000, 08:24 AM
So long as it doesn't need to scale beyond one web server, you can store the object in the application object.