爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8932|回复: 6

[求助] 哪位大神帮我看看这个程序的错误怎么改好吗···感激涕零

[复制链接]

新浪微博达人勋

发表于 2015-3-6 11:00:11 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
program server
         use KERNEL32
         use WS2_32
         implicit none
         integer WINSOCK_V2_2                        !版本
         integer connection_dropped_by_remote_party
         integer success
         parameter(WINSOCK_V2_2=X'202',connection_dropped_by_remote_party=X'05050505',success=0)
         type(T_SOCKADDR_IN) listenerInfo            !Server_add
         type(T_SOCKADDR_IN) connectionInfo          !client_add
         type(T_WSADATA) wsaInfo                     !版本信息结构
         type T_client_server_message
                union
                     map
                         integer receivelen        
                         integer sendlen      
                     end map
                     map
                       character*(100) receivebuffer
                       character*(100) sendbuffer
                     end map
                end union
         end type
         type(T_client_server_message)ClientServerMessage   
         integer connection        !socket_receive
         integer listener          !socket_server
         character*(15) host
         integer*2 port
         integer SendMsg            !send()
         integer ReceiveMsg         !recv()
         integer status
         ! Initialize Winsock v2.
         status=WSAStartup(WINSOCK_V2_2,wasInfo)
         if(status.NE.success)then
            write(*,*)'WSAStartup-',status
            stop
         end if
         ! 创建套接字
         listener=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)   
         if(listener.EQ.INVALID_SOCKET) then
             write(*,*)'socket-',INVALID_SOCKET
             status=WSACleanup()
             stop
         end if
         ! 设置连接地址
         host='0.0.0.0'
         port=55000
         listenerInfo%sin_family=AF_INET
         listenerInfo%sin_port=htons(port)
         listenerInfo%sin_addr%s_addr =inet_addr(host(1:LEN_TRIM(host)))
         ! 绑定套接字到某地的某个地址和端口
         status=bind(listener,%REF(listenerInfo),sizeof(listenerInfo))
         if(status.EQ.SOCKET_ERROR) then
            write(*,*)'bind -',WSAGetLastError()
            status = WSACleanup()
            stop
         end if
         !监听状态
         do while(.true.)
              status = listen(listener,1)
              if(status<0)then
                  write(*,*)'listen -'
                  status=WSACleanup()
                  stop
              end if
              !接受连接
              if (status.EQ.SUCCESS) then
                   connection=SOCKET_ERROR
                   do while(connection.EQ.SOCKET_ERROR)
                       connection=accept(listener,%REF(connectionInfo),0)
                       call sleep(100)
                    end do
                    !进行聊天
                    !接收数据
                    do while(.true.)
                        clientServerMessage%receivelen=recv(connection,clientServerMessage%receivebuffer,100,0)
                        if(clientServerMessage%receivelen<0)then
                           write(*,*)"接受失败,程序退出"
                           stop
                        else
                           write(*,*)"client say:",clientServerMessage%receivebuffer
                         end if
                       !发送数据
                          write(*,*)"please enter message:"
                          read(*,*) clientServerMessage%sendbuffer
                          clientServerMessage%sendlen=send(connection,clientServerMessage%sendbuffer,100,0)
                          if(clientServerMessage%sendlen<0)then
                            write(*,*)"发送失败"
                          end if
                     end do
                  end if
             end do
             status =closesocket(connection)
             status =closesocket(listener)
             status =WSACleanup()
             pause
        stop
        end








错误 26 Compilation Aborted (code 1) d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 1
警告 19  warning #7319: This argument's data type is incompatible with this intrinsic procedure; procedure assumed EXTERNAL.   [LEN_TRIM] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 58
错误 18  error #6514: A substring must be of type CHARACTER.   [HOST] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 58
错误 25  error #6460: This is not a field name that is defined in the encompassing structure.   [SENDLEN] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 102
错误 24  error #6460: This is not a field name that is defined in the encompassing structure.   [SENDBUFFER] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 101
错误 22  error #6460: This is not a field name that is defined in the encompassing structure.   [RECEIVELEN] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 92
错误 23  error #6460: This is not a field name that is defined in the encompassing structure.   [RECEIVEBUFFER] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 92
错误 14  error #6404: This name does not have a type, and must have an explicit type.   [WASINFO] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 37
错误 13  error #6404: This name does not have a type, and must have an explicit type.   [STATUS] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 37
错误 17  error #6404: This name does not have a type, and must have an explicit type.   [PORT] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 54
错误 15  error #6404: This name does not have a type, and must have an explicit type.   [LISTENER] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 44
错误 20  error #6404: This name does not have a type, and must have an explicit type.   [LEN_TRIM] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 58
错误 16  error #6404: This name does not have a type, and must have an explicit type.   [HOST] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 53
错误 21  error #6404: This name does not have a type, and must have an explicit type.   [CONNECTION] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 80
错误 12  error #6404: This name does not have a type, and must have an explicit type.   [CLIENTSERVERMESSAGE] d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 27
错误 4  error #6386: Confused statement; this is neither a valid I/O TYPE stmt, nor a valid F90 derived-type-stmt, nor a valid F90 type-declaration-stmt. d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 27
错误 5  error #6236: A specification statement cannot appear in the executable section. d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 28
错误 6  error #6236: A specification statement cannot appear in the executable section. d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 29
错误 7  error #6236: A specification statement cannot appear in the executable section. d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 30
错误 8  error #6236: A specification statement cannot appear in the executable section. d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 31
错误 9  error #6236: A specification statement cannot appear in the executable section. d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 32
错误 10  error #6236: A specification statement cannot appear in the executable section. d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 33
错误 11  error #6236: A specification statement cannot appear in the executable section. d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 34
错误 3  error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( * ) . % + - [ . ** / // d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 27
错误 1  error #5078: Unrecognized token 'T_client_server_message?' skipped d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 27
错误 2  error #5078: Unrecognized token '?' skipped d:\documents\visual studio 2010\Projects\Console9\Console9\Source1.f90 27

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-3-6 13:41:12 | 显示全部楼层
自己改的没有错误了···谢谢大家··
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-3-7 23:27:07 来自手机 | 显示全部楼层
改了什么地方?贴出来学习学习
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-3-13 12:51:41 | 显示全部楼层
qxtlyf 发表于 2015-3-7 23:27
改了什么地方?贴出来学习学习

status=WSAStartup(WINSOCK_V2_2,wasInfo)
最后一个wasinfo改成wsainfo···
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-3-14 09:17:15 | 显示全部楼层
lanxueren121 发表于 2015-3-13 12:51
status=WSAStartup(WINSOCK_V2_2,wasInfo)
最后一个wasinfo改成wsainfo···

谢谢了,版主
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-4-6 18:51:42 | 显示全部楼层

改了什么地方?贴出来学习学习
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-12-14 09:24:07 | 显示全部楼层
我想问一下这个错误怎么改呀
error #6514: A substring must be of type CHARACTER.   
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表