Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ソケットについて
Search
jambo-develop-team
March 11, 2024
0
28
ソケットについて
TCP/IP等ネットワークプロトコルを使って データを双方向で送受信するための手段
TCP/IPという技術を使いやすくした API、ライブラリのようなもの
jambo-develop-team
March 11, 2024
Tweet
Share
More Decks by jambo-develop-team
See All by jambo-develop-team
会社紹介資料_株式会社ジャンボ
jambo_develop_team
0
1.4k
株式会社Jambo紹介資料
jambo_develop_team
0
640
StoreKit2を使用した課金実装
jambo_develop_team
0
240
AppDelegateで何をすべきか
jambo_develop_team
0
310
SwiftUIのpropertyWrapperをふんわり理解する
jambo_develop_team
0
340
JetpackCompose触ってみた
jambo_develop_team
0
7
KMPを触ってみた
jambo_develop_team
0
17
モバイルアプリの通知機能を AmazonSNSで実装する
jambo_develop_team
0
28
アジャイル入門
jambo_develop_team
0
9
Featured
See All Featured
Writing Fast Ruby
sferik
628
61k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Into the Great Unknown - MozCon
thekraken
34
1.6k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
19
2.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
A better future with KSS
kneath
238
17k
Transcript
ીࠜݪޫҰ ιέοτʹ͍ͭͯ
None
ൃදͷత ιέοτ͕Կऀͳͷ͔ Կͱͳ͘ͰΠϝʔδͰ͖ΔΑ͏ʹ͢Δ
݁ہιέοτͬͯԿʁ
5$1*1 ʢݸਓతͳݟղʣ
5$1*1ωοτϫʔΫϓϩτίϧΛͬͯ σʔλΛํͰૹड৴͢ΔͨΊͷखஈ 5$1*1ͱ͍͏ٕज़Λ͍ͨ͘͢͠ "1*ɺϥΠϒϥϦͷΑ͏ͳͷ ͏গ͠۩ମతʹ
ͦͦ5$1*1ͬͯʁ
5$1*1ͱ ௨৴نɾ௨৴ʹ͓͚Δଋࣄ ΞϓϦέʔγϣϯ )551ɺ4.51ɺ%/4 τϥϯεϙʔτ 5$1ɺ6%1 Πϯλʔωοτ
*1ɺ"31ɺ3"31 ωοτϫʔΫΠϯλʔϑΣʔε &UIFSOFUɺ111
Πϯλʔωοτͷׂɺ*1ΞυϨεΛݩʹσʔλ ͷΓऔΓΛ͢Δ૬खΛࢦఆ͢Δ Πϯλʔωοτ
τϥϯεϙʔτͷׂɺσʔλΛదͳΞϓϦέ ʔγϣϯʹৼΓ͚Δ͜ͱ τϥϯεϙʔτ σʔλ σʔλ σʔλ ΞϓϦ" ΞϓϦ#
τϥϯεϙʔτͷׂɺσʔλΛదͳΞϓϦέ ʔγϣϯʹৼΓ͚Δ͜ͱ τϥϯεϙʔτ σʔλ σʔλ σʔλ ΞϓϦ" ΞϓϦ# ϙʔτ൪߸ΛݩʹৼΓ͚
τϥϯεϙʔτͷ௨৴ϓϩτίϧछྨ 5$1ͱ6%1
5$1 5SBOTNJTTJPO$POUSPM1SPUPDPM ૹ͍͍ͬͯʁ ͍͍Αʂ ૹΔͶʂ ίωΫγϣϯܕɹ৴པੑॏࢹ ϝʔϧϑΝΠϧͳͲ࣭ΛٻΊΔ௨৴ʹ༻͢Δ ͪΐͬͱࠞΈ ߹ͬͯΔ ແࣄड͚औͬͨΑʂ
όΠτૹ ΔͶʂ ࠶ૹ͢ΔͶʂ
5$1 5SBOTNJTTJPO$POUSPM1SPUPDPM ૹ͍͍ͬͯʁ ͍͍Αʂ ૹΔͶʂ ίωΫγϣϯܕɹ৴པੑॏࢹ ϝʔϧϑΝΠϧͳͲ࣭ΛٻΊΔ௨৴ʹ༻͢Δ ͪΐͬͱࠞΈ ߹ͬͯΔ ແࣄड͚औͬͨΑʂ
όΠτૹ ΔͶʂ ࠶ૹ͢ΔͶʂ ΣΠϋϯυγΣΠΫ
6%1 6TFS%BUBHSBN1SPUPDPM ͲΜͲΜૹΔΑʂ ίωΫγϣϯϨεܕɹεϐʔυॏࢹ *1ిετϦʔϛϯάαʔϏεͳͲରଟϦΞϧλΠϜੑΛٻΊΔ௨৴ ड͚औΓʹࣦഊ͠ ͓ͯߏ͍ͳ͠ ؾʹͤͣૹΔΑʂ
ৄͪ͘͜͠Β εϥεϥΘ͔ΔωοτϫʔΫ 5$1*1ͷ͖΄Μ
5$1*1͔͚ͬͨͲιέοτʁ
5$1ʹ͓͚Διέοτ௨৴ͷྲྀΕʹ͍ͭͯ ιέοτ௨৴͢ΔػثɺͦΕͧΕͰιέοτͷ࣮͕ඞཁ ίωΫγϣϯͷ४උ ίωΫγϣϯͷཱ֬ σʔλަ ίωΫγϣϯͷղ์
αʔόʔ ΫϥΠΞϯτ 4PDLFU 4PDLFU MJTUFO DPOOFDU SFDFJWF TFOE SFDFJWF TFOE
DMPTF DMPTF ίωΫγϣϯ४උ ίωΫγϣϯཱ֬ σʔλަ ίωΫγϣϯղ๏
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: CustomUrl.Port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 J04ΞϓϦ ιέοτॳظԽॲཧ ίωΫγϣϯͷ४උ ίωΫγϣϯཱ֬
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: ɹɹɹɹɹɹɹɹɹɹɹCustomUrl.port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 Πϯλʔωοτ τϥϯεϙʔτ τϥϯεϙʔτ ʁʁʁ
ιέοτΫϥΠΞϯτଆ final class SocketClient { init(_ loginUser: LoginUserEntity) { self.loginUser
= loginUser let host = NWEndpoint.Host(CustomUrl.targetIp) let port = NWEndpoint.Port(integerLiteral: ɹɹɹɹɹɹɹɹɹɹɹCustomUrl.port) let using: NWParameters = .tcp connection = NWConnection(host: host, port: port, using: using) connection.stateUpdateHandler = {[weak self] newState in guard let strongSelf = self else { return } strongSelf.connectionState = newState switch newState { case .setup: print("HOGE: ηοτΞοϓ”) case .waiting: print("HOGE: ػ") case .preparing: print("HOGE: ४උ") case .ready: print("HOGE: ४උྃ”) private static let productionIp = “xxx.com” static let port: UInt16 = 8_888 Πϯλʔωοτ τϥϯεϙʔτ τϥϯεϙʔτ ΣΠϋϯυγΣΠΫ
ιέοτΫϥΠΞϯτଆ func send(to receiver: SocketMsgProtocol, text: String, messageType: ChatMessageType, handler:
@escaping (SocketMessage?) -> Void) { ~~~~ } func receive(on connection: NWConnection) { connection.receive(minimumIncompleteLength: 0, maximumLength: Int(UInt32.max)) {[weak self] (data, _, _, error) in guard let text = data?.toStringWithEncodeByUTF8() ~~~ } σʔλަ
ιέοτΫϥΠΞϯτଆ func releaseSocketClient() { socketClient = nil } ɹɹdeinit {
connection.cancel() } ίωΫγϣϯͷղ์
·ͱΊ w 5$1*1ͷٕज़Λͬͯ؆୯ʹσʔλͷΓऔΓΛߦ͑ΔΑ͏ ʹͨ͠ͷ͕ιέοτ w 5$1ͱ6%1ͱ͍͏̎ͭͷ௨৴ϓϩτίϧ͕͋Δ w ࣄͷຊ࣭Λָ͍ͬͯ͘͠͞
͓ΘΓ